Documentation
¶
Index ¶
- func DocumentHighlight(rootNode *parser.GroupStatementNode, position lexer.Position) []lexer.Range
- func FoldingRange(rootNode *parser.GroupStatementNode) ([]*parser.GroupStatementNode, []*parser.CommentNode)
- func Format(source []byte, opts FormatOptions) []byte
- func GetWorkspaceCustomFunctions() map[string]*checker.FunctionDefinition
- func GoToDefinition(file *checker.FileDefinition, position lexer.Position) (fileNames []string, ranges []lexer.Range, err error)
- func HasFileExtension(fileName string, extensions []string) bool
- func Hover(file *checker.FileDefinition, position lexer.Position) (string, lexer.Range)
- func OpenProjectFiles(rootDir string, withFileExtensions []string) map[string][]byte
- func Print(node ...parser.AstNode)
- func SetWorkspaceCustomFunctions(funcs map[string]*checker.FunctionDefinition)
- type DocumentLinkInfo
- type Error
- func DefinitionAnalysisSingleFile(fileName string, parsedFilesInWorkspace map[string]*parser.GroupStatementNode) (*checker.FileDefinition, []Error)
- func ParseFilesInWorkspace(workspaceFiles map[string][]byte) (map[string]*parser.GroupStatementNode, []Error)
- func ParseSingleFile(source []byte) (*parser.GroupStatementNode, []Error)
- type FileAnalysisAndError
- func DefinitionAnalysisChainTriggeredByBatchFileChange(parsedFilesInWorkspace map[string]*parser.GroupStatementNode, ...) []FileAnalysisAndError
- func DefinitionAnalysisChainTriggeredBySingleFileChange(parsedFilesInWorkspace map[string]*parser.GroupStatementNode, fileName string) []FileAnalysisAndError
- func DefinitionAnalysisWithinWorkspace(parsedFilesInWorkspace map[string]*parser.GroupStatementNode) []FileAnalysisAndError
- type FormatOptions
- type FunctionDefinition
- type SemanticToken
- type SemanticTokenModifier
- type SemanticTokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DocumentHighlight ¶
func DocumentHighlight( rootNode *parser.GroupStatementNode, position lexer.Position, ) []lexer.Range
DocumentHighlight returns the keyword ranges of all linked control flow keywords when the cursor is on one of them. For example, if the cursor is on {{if}}, {{else}}, or {{end}}, all related keywords in the same control flow block are highlighted.
func FoldingRange ¶
func FoldingRange( rootNode *parser.GroupStatementNode, ) ([]*parser.GroupStatementNode, []*parser.CommentNode)
func Format ¶ added in v0.7.0
func Format(source []byte, opts FormatOptions) []byte
Format re-indents the source based on HTML tag and Go template control block nesting. Only leading whitespace is changed; content within lines is never modified. When PrintWidth > 0, opening HTML tags that exceed the width are wrapped.
func GetWorkspaceCustomFunctions ¶
func GetWorkspaceCustomFunctions() map[string]*checker.FunctionDefinition
GetWorkspaceCustomFunctions returns the currently set custom template functions.
func GoToDefinition ¶
func HasFileExtension ¶
HasFileExtension reports whether fileName's extension is found within extensions.
func OpenProjectFiles ¶
OpenProjectFiles recursively opens files from 'rootDir'. There is a depth limit for the recursion (current MAX_DEPTH = 5).
func SetWorkspaceCustomFunctions ¶
func SetWorkspaceCustomFunctions(funcs map[string]*checker.FunctionDefinition)
SetWorkspaceCustomFunctions sets the custom template functions for the workspace. These functions are discovered by scanning Go source files for template.FuncMap definitions. Call this once when initializing the workspace.
Types ¶
type DocumentLinkInfo ¶ added in v0.10.0
type DocumentLinkInfo struct {
Range lexer.Range // range of the template name (without quotes)
TemplateName string // the template name
TargetURI string // resolved file URI of the template definition, if known
}
DocumentLinkInfo represents a template call that should be rendered as a clickable link.
func DocumentLinks ¶ added in v0.10.0
func DocumentLinks(rootNode *parser.GroupStatementNode) []DocumentLinkInfo
DocumentLinks returns document links for all template calls in the AST. Each link covers the template name (without quotes) in {{template "name"}} calls.
type Error ¶
func DefinitionAnalysisSingleFile ¶
func DefinitionAnalysisSingleFile( fileName string, parsedFilesInWorkspace map[string]*parser.GroupStatementNode, ) (*checker.FileDefinition, []Error)
DefinitionAnalysisSingleFile performs semantic analysis on a single file. Use DefinitionAnalysisChainTriggeredBySingleFileChange instead for better performance.
func ParseFilesInWorkspace ¶
func ParseFilesInWorkspace( workspaceFiles map[string][]byte, ) (map[string]*parser.GroupStatementNode, []Error)
ParseFilesInWorkspace parses all files within a workspace using parallel goroutines. Returns AST nodes and error list. Never returns nil, always an empty 'map' if nothing found. Files are parsed concurrently for improved performance on multi-core systems.
func ParseSingleFile ¶
func ParseSingleFile(source []byte) (*parser.GroupStatementNode, []Error)
ParseSingleFile parses file content (buffer) and returns an AST node and error list. Returned parse tree is never 'nil', even when empty.
type FileAnalysisAndError ¶
type FileAnalysisAndError struct {
FileName string
File *checker.FileDefinition
Errs []lexer.Error
}
FileAnalysisAndError pairs analysis results with any errors for a single file.
func DefinitionAnalysisChainTriggeredByBatchFileChange ¶
func DefinitionAnalysisChainTriggeredByBatchFileChange( parsedFilesInWorkspace map[string]*parser.GroupStatementNode, fileNames ...string, ) []FileAnalysisAndError
DefinitionAnalysisChainTriggeredByBatchFileChange computes semantic analysis for multiple file changes.
func DefinitionAnalysisChainTriggeredBySingleFileChange ¶
func DefinitionAnalysisChainTriggeredBySingleFileChange( parsedFilesInWorkspace map[string]*parser.GroupStatementNode, fileName string, ) []FileAnalysisAndError
DefinitionAnalysisChainTriggeredBySingleFileChange computes semantic analysis for a file and all affected files.
func DefinitionAnalysisWithinWorkspace ¶
func DefinitionAnalysisWithinWorkspace( parsedFilesInWorkspace map[string]*parser.GroupStatementNode, ) []FileAnalysisAndError
DefinitionAnalysisWithinWorkspace performs definition analysis for all files in a workspace.
type FormatOptions ¶ added in v0.7.0
type FormatOptions struct {
TabSize int
InsertSpaces bool
PrintWidth int // 0 = disabled, default 120
AttrWrapMode string // "overflow" or "all"
}
FormatOptions holds configuration for the formatter.
type FunctionDefinition ¶
type FunctionDefinition = checker.FunctionDefinition
FunctionDefinition is an alias to allow external packages to work with custom functions.
type SemanticToken ¶
type SemanticToken struct {
Line int
StartChar int
Length int
TokenType SemanticTokenType
Modifiers SemanticTokenModifier
}
SemanticToken represents a single semantic token with position and type info.
func SemanticTokens ¶
func SemanticTokens(rootNode *parser.GroupStatementNode) []SemanticToken
SemanticTokens extracts semantic tokens from a parsed template AST. It walks the AST and returns tokens suitable for LSP semantic highlighting.
type SemanticTokenModifier ¶
type SemanticTokenModifier int
SemanticTokenModifier represents semantic token modifiers for LSP.
const ( SemanticModifierDeclaration SemanticTokenModifier = 1 << iota SemanticModifierDefinition SemanticModifierReadonly )
Semantic token modifiers (bit flags, must match the legend in lsp/protocol.go).
type SemanticTokenType ¶
type SemanticTokenType int
SemanticTokenType represents semantic token types for LSP.
const ( SemanticTokenKeyword SemanticTokenType = iota SemanticTokenVariable SemanticTokenFunction SemanticTokenProperty SemanticTokenString SemanticTokenNumber SemanticTokenOperator SemanticTokenComment )
Semantic token types (must match the legend in lsp/protocol.go).