package template
import "golang.org/x/tools/internal/lsp/template"
Package template contains code for dealing with templates
Index ¶
- Variables
- func Completion(ctx context.Context, snapshot source.Snapshot, fh source.VersionedFileHandle, pos protocol.Position, context protocol.CompletionContext) (*protocol.CompletionList, error)
- func Definition(snapshot source.Snapshot, fh source.VersionedFileHandle, loc protocol.Position) ([]protocol.Location, error)
- func Diagnose(f source.VersionedFileHandle) []*source.Diagnostic
- func DocumentSymbols(snapshot source.Snapshot, fh source.FileHandle) ([]protocol.DocumentSymbol, error)
- func Highlight(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, loc protocol.Position) ([]protocol.DocumentHighlight, error)
- func Hover(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, position protocol.Position) (*protocol.Hover, error)
- func References(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, params *protocol.ReferenceParams) ([]protocol.Location, error)
- func SemanticTokens(ctx context.Context, snapshot source.Snapshot, spn span.URI, add func(line, start, len uint32), d func() []uint32) (*protocol.SemanticTokens, error)
- type All
- type Parsed
- func (p *Parsed) FindLiteralBefore(pos int) (int, int)
- func (p *Parsed) FromPosition(x protocol.Position) int
- func (p *Parsed) LineCol(x int) (uint32, uint32)
- func (p *Parsed) Position(pos int) protocol.Position
- func (p *Parsed) Range(x, length int) protocol.Range
- func (p *Parsed) RuneCount(l, s, e uint32) uint32
- func (p *Parsed) SymsAtPos(pos int) []symbol
- func (p *Parsed) TokenSize(t Token) (int, error)
- func (p *Parsed) Tokens() []Token
- func (p *Parsed) WriteNode(w io.Writer, n parse.Node)
- type Token
Variables ¶
Functions ¶
func Completion ¶
func Completion(ctx context.Context, snapshot source.Snapshot, fh source.VersionedFileHandle, pos protocol.Position, context protocol.CompletionContext) (*protocol.CompletionList, error)
func Definition ¶
func Definition(snapshot source.Snapshot, fh source.VersionedFileHandle, loc protocol.Position) ([]protocol.Location, error)
Definition finds the definitions of the symbol at loc. It does not understand scoping (if any) in templates. This code is for defintions, type definitions, and implementations. Results only for variables and templates.
func Diagnose ¶
func Diagnose(f source.VersionedFileHandle) []*source.Diagnostic
Diagnose returns parse errors. There is only one. The errors are not always helpful. For instance { {end}} will likely point to the end of the file.
func DocumentSymbols ¶
func DocumentSymbols(snapshot source.Snapshot, fh source.FileHandle) ([]protocol.DocumentSymbol, error)
DocumentSymbols returns a heirarchy of the symbols defined in a template file. (The heirarchy is flat. SymbolInformation might be better.)
func Highlight ¶
func Highlight(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, loc protocol.Position) ([]protocol.DocumentHighlight, error)
func Hover ¶
func Hover(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, position protocol.Position) (*protocol.Hover, error)
func References ¶
func References(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, params *protocol.ReferenceParams) ([]protocol.Location, error)
func SemanticTokens ¶
func SemanticTokens(ctx context.Context, snapshot source.Snapshot, spn span.URI, add func(line, start, len uint32), d func() []uint32) (*protocol.SemanticTokens, error)
Types ¶
type All ¶
type All struct {
// contains filtered or unexported fields
}
All contains the Parse of all the template files
func New ¶
func New(tmpls map[span.URI]source.VersionedFileHandle) *All
New returns the Parses of the snapshot's tmpl files (maybe cache these, but then avoiding import cycles needs code rearrangements)
type Parsed ¶
type Parsed struct { ParseErr error // contains filtered or unexported fields }
func (*Parsed) FindLiteralBefore ¶
FindLiteralBefore locates the first preceding string literal returning its position and length in buf or returns -1 if there is none. Assume "", rather than “, for now
func (*Parsed) FromPosition ¶
FromPosition translates a protocol.Position into an offset into the template
func (*Parsed) LineCol ¶
LineCol converts from a 0-based byte offset to 0-based line, col. col in runes
func (*Parsed) Position ¶
Position produces a protocol.Position from an offset in the template
func (*Parsed) Range ¶
func (*Parsed) RuneCount ¶
RuneCount counts runes in a line
func (*Parsed) SymsAtPos ¶
func (*Parsed) TokenSize ¶
func (*Parsed) Tokens ¶
func (*Parsed) WriteNode ¶
WriteNode is for debugging
type Token ¶
Token is a single {{...}}. More precisely, Left...Right
Source Files ¶
completion.go highlight.go implementations.go parse.go symbols.go
- Version
- v0.1.10
- Published
- Mar 15, 2022
- Platform
- js/wasm
- Imports
- 20 packages
- Last checked
- 6 hours ago –
Tools for package owners.