Documentation
¶
Overview ¶
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- type Handler
- func (h *Handler) AnalyzeCompletionContext(doc types.Document, position protocol.Position) *types.CompletionAnalysis
- func (h *Handler) Close()
- func (h *Handler) CreateDocument(uri, content string, version int32) types.Document
- func (h *Handler) FindAttributeAtPosition(doc types.Document, position protocol.Position) (*types.AttributeMatch, string)
- func (h *Handler) FindCustomElements(doc types.Document) ([]types.CustomElementMatch, error)
- func (h *Handler) FindElementAtPosition(doc types.Document, position protocol.Position) *types.CustomElementMatch
- func (h *Handler) Language() string
- type TSXDocument
- func (d *TSXDocument) AnalyzeCompletionContextTS(position protocol.Position, dm any) *types.CompletionAnalysis
- func (d *TSXDocument) ByteRangeToProtocolRange(content string, startByte, endByte uint) protocol.Range
- func (d *TSXDocument) Close()
- func (d *TSXDocument) CompletionPrefix(analysis *types.CompletionAnalysis) string
- func (d *TSXDocument) Content() (string, error)
- func (d *TSXDocument) FindAttributeAtPosition(position protocol.Position, dm any) (*types.AttributeMatch, string)
- func (d *TSXDocument) FindCustomElements(dm any) ([]types.CustomElementMatch, error)
- func (d *TSXDocument) FindElementAtPosition(position protocol.Position, dm any) *types.CustomElementMatch
- func (d *TSXDocument) FindHeadInsertionPoint(dm any) (protocol.Position, bool)
- func (d *TSXDocument) FindInlineModuleScript() (protocol.Position, bool)
- func (d *TSXDocument) FindModuleScript() (protocol.Position, bool)
- func (d *TSXDocument) ImportMap() map[string]string
- func (d *TSXDocument) Language() string
- func (d *TSXDocument) Parse(content string) error
- func (d *TSXDocument) Parser() *ts.Parser
- func (d *TSXDocument) ScriptTags() []types.ScriptTag
- func (d *TSXDocument) SetParser(parser *ts.Parser)
- func (d *TSXDocument) SetScriptTags(scriptTags []types.ScriptTag)
- func (d *TSXDocument) SetTree(tree *ts.Tree)
- func (d *TSXDocument) Tree() *ts.Tree
- func (d *TSXDocument) URI() string
- func (d *TSXDocument) UpdateContent(content string, version int32)
- func (d *TSXDocument) Version() int32
Constants ¶
const ( // Base scores for different completion types (lower scores are more specific) SCORE_TAG_NAME_BASE = 10 // Most specific: tag name completion SCORE_ATTR_NAME_BASE = 20 // Medium specificity: attribute name completion SCORE_ATTR_VALUE_BASE = 30 // Least specific: attribute value completion // Bonus/penalty scoring factors SCORE_CURSOR_BONUS = 50 // Large bonus for captures containing cursor SCORE_BROAD_CAPTURE_PENALTY = 5 // Penalty multiplier for broad captures (ERROR nodes) // Thresholds for completion analysis MAX_REASONABLE_TAG_LENGTH = 10 // Threshold for reasonable tag name length )
Completion scoring constants for prioritizing tree-sitter captures
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements language-specific operations for TSX documents
func NewHandler ¶
func NewHandler(queryManager *Q.QueryManager) (*Handler, error)
NewHandler creates a new TSX language handler
func (*Handler) AnalyzeCompletionContext ¶
func (h *Handler) AnalyzeCompletionContext(doc types.Document, position protocol.Position) *types.CompletionAnalysis
AnalyzeCompletionContext analyzes completion context for TSX documents
func (*Handler) CreateDocument ¶
CreateDocument creates a new TSX document
func (*Handler) FindAttributeAtPosition ¶
func (h *Handler) FindAttributeAtPosition(doc types.Document, position protocol.Position) (*types.AttributeMatch, string)
FindAttributeAtPosition finds an attribute at the given position
func (*Handler) FindCustomElements ¶
FindCustomElements finds custom elements in TSX documents
func (*Handler) FindElementAtPosition ¶
func (h *Handler) FindElementAtPosition(doc types.Document, position protocol.Position) *types.CustomElementMatch
FindElementAtPosition finds a custom element at the given position
type TSXDocument ¶
type TSXDocument struct {
// contains filtered or unexported fields
}
TSXDocument represents a TSX document with tree-sitter parsing
func (*TSXDocument) AnalyzeCompletionContextTS ¶
func (d *TSXDocument) AnalyzeCompletionContextTS(position protocol.Position, dm any) *types.CompletionAnalysis
AnalyzeCompletionContextTS analyzes completion context using tree-sitter queries (interface method)
func (*TSXDocument) ByteRangeToProtocolRange ¶
func (d *TSXDocument) ByteRangeToProtocolRange(content string, startByte, endByte uint) protocol.Range
ByteRangeToProtocolRange converts byte range to protocol range
func (*TSXDocument) CompletionPrefix ¶
func (d *TSXDocument) CompletionPrefix(analysis *types.CompletionAnalysis) string
CompletionPrefix extracts the prefix being typed for filtering completions
func (*TSXDocument) Content ¶
func (d *TSXDocument) Content() (string, error)
Content returns the document content
func (*TSXDocument) FindAttributeAtPosition ¶
func (d *TSXDocument) FindAttributeAtPosition(position protocol.Position, dm any) (*types.AttributeMatch, string)
FindAttributeAtPosition finds an attribute at the given position (interface method)
func (*TSXDocument) FindCustomElements ¶
func (d *TSXDocument) FindCustomElements(dm any) ([]types.CustomElementMatch, error)
FindCustomElements finds custom elements in the document (interface method)
func (*TSXDocument) FindElementAtPosition ¶
func (d *TSXDocument) FindElementAtPosition(position protocol.Position, dm any) *types.CustomElementMatch
FindElementAtPosition finds a custom element at the given position (interface method)
func (*TSXDocument) FindHeadInsertionPoint ¶
func (d *TSXDocument) FindHeadInsertionPoint(dm any) (protocol.Position, bool)
FindHeadInsertionPoint finds insertion point in <head> section
func (*TSXDocument) FindInlineModuleScript ¶
func (d *TSXDocument) FindInlineModuleScript() (protocol.Position, bool)
FindInlineModuleScript finds insertion point in inline module script
func (*TSXDocument) FindModuleScript ¶
func (d *TSXDocument) FindModuleScript() (protocol.Position, bool)
FindModuleScript finds insertion point in module script
func (*TSXDocument) ImportMap ¶ added in v0.8.0
func (d *TSXDocument) ImportMap() map[string]string
ImportMap returns nil for TSX documents (no importmaps in TSX files)
func (*TSXDocument) Language ¶
func (d *TSXDocument) Language() string
Language returns the document language
func (*TSXDocument) Parse ¶
func (d *TSXDocument) Parse(content string) error
Parse parses the TSX content using tree-sitter
func (*TSXDocument) Parser ¶
func (d *TSXDocument) Parser() *ts.Parser
Parser returns the document's parser
func (*TSXDocument) ScriptTags ¶
func (d *TSXDocument) ScriptTags() []types.ScriptTag
ScriptTags returns the parsed script tags
func (*TSXDocument) SetParser ¶
func (d *TSXDocument) SetParser(parser *ts.Parser)
SetParser sets the document's parser
func (*TSXDocument) SetScriptTags ¶
func (d *TSXDocument) SetScriptTags(scriptTags []types.ScriptTag)
SetScriptTags sets the script tags
func (*TSXDocument) SetTree ¶
func (d *TSXDocument) SetTree(tree *ts.Tree)
SetTree sets the document's syntax tree
func (*TSXDocument) Tree ¶
func (d *TSXDocument) Tree() *ts.Tree
Tree returns the document's syntax tree
func (*TSXDocument) UpdateContent ¶
func (d *TSXDocument) UpdateContent(content string, version int32)
UpdateContent updates the document content
func (*TSXDocument) Version ¶
func (d *TSXDocument) Version() int32
Version returns the document version