Documentation
¶
Index ¶
- type Definition
- type DefinitionExtractor
- func (de *DefinitionExtractor) ExtractDefinitions(result *ParseResult) ([]Definition, error)
- func (de *DefinitionExtractor) ExtractDefinitionsByType(result *ParseResult, defType DefinitionType) ([]Definition, error)
- func (de *DefinitionExtractor) FindDefinition(result *ParseResult, name string) (*Definition, error)
- type DefinitionType
- type Language
- type Parameter
- type ParseResult
- type ParserConfig
- type QueryBuilder
- type QueryMatch
- type QueryPattern
- type QueryResult
- type QuerySystem
- func (qs *QuerySystem) AddCustomPattern(language Language, queryType QueryType, pattern string, captures []string) error
- func (qs *QuerySystem) ClearCache()
- func (qs *QuerySystem) ExecuteCustomQuery(result *ParseResult, queryPattern string) (*QueryResult, error)
- func (qs *QuerySystem) ExecuteQuery(result *ParseResult, queryType QueryType) (*QueryResult, error)
- func (qs *QuerySystem) FindNodesByName(result *ParseResult, name string) ([]QueryMatch, error)
- func (qs *QuerySystem) FindNodesByType(result *ParseResult, nodeType string) ([]QueryMatch, error)
- func (qs *QuerySystem) GetAllDefinitions(result *ParseResult) (map[QueryType][]QueryMatch, error)
- func (qs *QuerySystem) GetAvailableQueries(language Language) []QueryType
- func (qs *QuerySystem) GetCacheStats() map[string]interface{}
- func (qs *QuerySystem) GetPattern(language Language, queryType QueryType) (*QueryPattern, error)
- type QueryType
- type TreeSitterParser
- func (tsp *TreeSitterParser) ClearCache()
- func (tsp *TreeSitterParser) DetectLanguage(filePath string) Language
- func (tsp *TreeSitterParser) FindNodesOfType(root *sitter.Node, nodeType string) []*sitter.Node
- func (tsp *TreeSitterParser) GetCacheStats() map[string]interface{}
- func (tsp *TreeSitterParser) GetChildByType(node *sitter.Node, nodeType string) *sitter.Node
- func (tsp *TreeSitterParser) GetChildrenByType(node *sitter.Node, nodeType string) []*sitter.Node
- func (tsp *TreeSitterParser) GetNodeLocation(node *sitter.Node) (startLine, startCol, endLine, endCol uint32)
- func (tsp *TreeSitterParser) GetNodeText(node *sitter.Node, content string) string
- func (tsp *TreeSitterParser) GetSupportedLanguages() []Language
- func (tsp *TreeSitterParser) IsLanguageSupported(language Language) bool
- func (tsp *TreeSitterParser) NodeToString(node *sitter.Node, content string, maxDepth int) string
- func (tsp *TreeSitterParser) ParseContent(content string, language Language, filePath string) (*ParseResult, error)
- func (tsp *TreeSitterParser) ParseFile(filePath string) (*ParseResult, error)
- func (tsp *TreeSitterParser) TraverseTree(root *sitter.Node, visitor func(*sitter.Node, int) bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Definition ¶
type Definition struct {
Type DefinitionType `json:"type"`
Name string `json:"name"`
Signature string `json:"signature"`
Summary string `json:"summary"`
FilePath string `json:"file_path"`
StartLine uint32 `json:"start_line"`
StartColumn uint32 `json:"start_column"`
EndLine uint32 `json:"end_line"`
EndColumn uint32 `json:"end_column"`
Language Language `json:"language"`
Content string `json:"content"`
DocString string `json:"doc_string,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
ReturnType string `json:"return_type,omitempty"`
Receiver string `json:"receiver,omitempty"` // For Go methods
Package string `json:"package,omitempty"`
Modifiers []string `json:"modifiers,omitempty"` // public, private, static, etc.
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Definition represents a code definition extracted from AST
type DefinitionExtractor ¶
type DefinitionExtractor struct {
// contains filtered or unexported fields
}
DefinitionExtractor extracts code definitions from AST
func NewDefinitionExtractor ¶
func NewDefinitionExtractor(parser *TreeSitterParser) *DefinitionExtractor
NewDefinitionExtractor creates a new definition extractor
func (*DefinitionExtractor) ExtractDefinitions ¶
func (de *DefinitionExtractor) ExtractDefinitions(result *ParseResult) ([]Definition, error)
ExtractDefinitions extracts all definitions from a parsed AST
func (*DefinitionExtractor) ExtractDefinitionsByType ¶
func (de *DefinitionExtractor) ExtractDefinitionsByType(result *ParseResult, defType DefinitionType) ([]Definition, error)
ExtractDefinitionsByType extracts definitions of a specific type
func (*DefinitionExtractor) FindDefinition ¶
func (de *DefinitionExtractor) FindDefinition(result *ParseResult, name string) (*Definition, error)
FindDefinition finds a specific definition by name
type DefinitionType ¶
type DefinitionType string
DefinitionType represents different types of code definitions
const ( DefFunction DefinitionType = "function" DefMethod DefinitionType = "method" DefClass DefinitionType = "class" DefStruct DefinitionType = "struct" DefInterface DefinitionType = "interface" DefType DefinitionType = "type" DefVariable DefinitionType = "variable" DefConstant DefinitionType = "constant" DefImport DefinitionType = "import" DefPackage DefinitionType = "package" )
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
Type string `json:"type"`
Default string `json:"default,omitempty"`
}
Parameter represents a function or method parameter
type ParseResult ¶
type ParseResult struct {
Language Language `json:"language"`
FilePath string `json:"file_path"`
Content string `json:"content"`
Tree *sitter.Tree `json:"-"`
RootNode *sitter.Node `json:"-"`
ParseTime time.Duration `json:"parse_time"`
NodeCount uint32 `json:"node_count"`
Error string `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
ParseResult contains the result of parsing a file
type ParserConfig ¶
type ParserConfig struct {
CacheSize int `json:"cache_size"`
ParseTimeout time.Duration `json:"parse_timeout"`
MaxFileSize int64 `json:"max_file_size"`
EnableLogging bool `json:"enable_logging"`
LazyLoad bool `json:"lazy_load"`
}
ParserConfig configures the tree-sitter parser behavior
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder helps build complex queries programmatically
func NewQueryBuilder ¶
func NewQueryBuilder(language Language) *QueryBuilder
NewQueryBuilder creates a new query builder
func (*QueryBuilder) AddCapture ¶
func (qb *QueryBuilder) AddCapture(capture string) *QueryBuilder
AddCapture adds a capture to the query
func (*QueryBuilder) AddPattern ¶
func (qb *QueryBuilder) AddPattern(pattern string) *QueryBuilder
AddPattern adds a pattern to the query
func (*QueryBuilder) Build ¶
func (qb *QueryBuilder) Build() string
Build builds the final query string
type QueryMatch ¶
type QueryMatch struct {
Node *sitter.Node `json:"-"`
Text string `json:"text"`
StartLine uint32 `json:"start_line"`
StartColumn uint32 `json:"start_column"`
EndLine uint32 `json:"end_line"`
EndColumn uint32 `json:"end_column"`
Captures map[string]string `json:"captures,omitempty"`
Context string `json:"context,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
QueryMatch represents a single match from a query
type QueryPattern ¶
type QueryPattern struct {
Language Language `json:"language"`
Type QueryType `json:"type"`
Pattern string `json:"pattern"`
Captures []string `json:"captures"`
}
QueryPattern represents a tree-sitter query pattern for a specific language
type QueryResult ¶
type QueryResult struct {
Type QueryType `json:"type"`
Language Language `json:"language"`
Matches []QueryMatch `json:"matches"`
ExecuteTime time.Duration `json:"execute_time"`
NodeCount int `json:"node_count"`
Error string `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
QueryResult represents the result of a tree-sitter query
type QuerySystem ¶
type QuerySystem struct {
// contains filtered or unexported fields
}
QuerySystem manages tree-sitter queries for multiple languages
func NewQuerySystem ¶
func NewQuerySystem(parser *TreeSitterParser) *QuerySystem
NewQuerySystem creates a new query system
func (*QuerySystem) AddCustomPattern ¶
func (qs *QuerySystem) AddCustomPattern(language Language, queryType QueryType, pattern string, captures []string) error
AddCustomPattern adds a custom query pattern
func (*QuerySystem) ClearCache ¶
func (qs *QuerySystem) ClearCache()
ClearCache clears the query result cache
func (*QuerySystem) ExecuteCustomQuery ¶
func (qs *QuerySystem) ExecuteCustomQuery(result *ParseResult, queryPattern string) (*QueryResult, error)
ExecuteCustomQuery executes a custom query pattern
func (*QuerySystem) ExecuteQuery ¶
func (qs *QuerySystem) ExecuteQuery(result *ParseResult, queryType QueryType) (*QueryResult, error)
ExecuteQuery executes a specific query type on a parse result
func (*QuerySystem) FindNodesByName ¶
func (qs *QuerySystem) FindNodesByName(result *ParseResult, name string) ([]QueryMatch, error)
FindNodesByName finds all nodes with a specific name
func (*QuerySystem) FindNodesByType ¶
func (qs *QuerySystem) FindNodesByType(result *ParseResult, nodeType string) ([]QueryMatch, error)
FindNodesByType finds all nodes of a specific type
func (*QuerySystem) GetAllDefinitions ¶
func (qs *QuerySystem) GetAllDefinitions(result *ParseResult) (map[QueryType][]QueryMatch, error)
GetAllDefinitions returns all definitions using the appropriate query types
func (*QuerySystem) GetAvailableQueries ¶
func (qs *QuerySystem) GetAvailableQueries(language Language) []QueryType
GetAvailableQueries returns available query types for a language
func (*QuerySystem) GetCacheStats ¶
func (qs *QuerySystem) GetCacheStats() map[string]interface{}
GetCacheStats returns cache statistics
func (*QuerySystem) GetPattern ¶
func (qs *QuerySystem) GetPattern(language Language, queryType QueryType) (*QueryPattern, error)
GetPattern returns a query pattern for a language and query type
type QueryType ¶
type QueryType string
QueryType represents different types of tree-sitter queries
const ( QueryFunctions QueryType = "functions" QueryMethods QueryType = "methods" QueryClasses QueryType = "classes" QueryStructs QueryType = "structs" QueryInterfaces QueryType = "interfaces" QueryTypes QueryType = "types" QueryVariables QueryType = "variables" QueryConstants QueryType = "constants" QueryImports QueryType = "imports" QueryComments QueryType = "comments" QueryDocStrings QueryType = "docstrings" QueryErrors QueryType = "errors" QueryAll QueryType = "all" )
type TreeSitterParser ¶
type TreeSitterParser struct {
// contains filtered or unexported fields
}
TreeSitterParser provides multi-language AST parsing capabilities
func NewTreeSitterParser ¶
func NewTreeSitterParser(config ParserConfig) (*TreeSitterParser, error)
NewTreeSitterParser creates a new tree-sitter parser instance
func (*TreeSitterParser) ClearCache ¶
func (tsp *TreeSitterParser) ClearCache()
ClearCache clears the parser cache
func (*TreeSitterParser) DetectLanguage ¶
func (tsp *TreeSitterParser) DetectLanguage(filePath string) Language
DetectLanguage detects the programming language from file extension
func (*TreeSitterParser) FindNodesOfType ¶
FindNodesOfType finds all nodes of a specific type
func (*TreeSitterParser) GetCacheStats ¶
func (tsp *TreeSitterParser) GetCacheStats() map[string]interface{}
GetCacheStats returns cache statistics
func (*TreeSitterParser) GetChildByType ¶
GetChildByType finds the first child node of a specific type
func (*TreeSitterParser) GetChildrenByType ¶
GetChildrenByType finds all child nodes of a specific type
func (*TreeSitterParser) GetNodeLocation ¶
func (tsp *TreeSitterParser) GetNodeLocation(node *sitter.Node) (startLine, startCol, endLine, endCol uint32)
GetNodeLocation returns the line and column information for a node
func (*TreeSitterParser) GetNodeText ¶
func (tsp *TreeSitterParser) GetNodeText(node *sitter.Node, content string) string
GetNodeText returns the text content of a node
func (*TreeSitterParser) GetSupportedLanguages ¶
func (tsp *TreeSitterParser) GetSupportedLanguages() []Language
GetSupportedLanguages returns a list of supported languages
func (*TreeSitterParser) IsLanguageSupported ¶
func (tsp *TreeSitterParser) IsLanguageSupported(language Language) bool
IsLanguageSupported checks if a language is supported
func (*TreeSitterParser) NodeToString ¶
NodeToString provides a debug representation of a node
func (*TreeSitterParser) ParseContent ¶
func (tsp *TreeSitterParser) ParseContent(content string, language Language, filePath string) (*ParseResult, error)
ParseContent parses the given content with the specified language
func (*TreeSitterParser) ParseFile ¶
func (tsp *TreeSitterParser) ParseFile(filePath string) (*ParseResult, error)
ParseFile parses a file and returns the AST
func (*TreeSitterParser) TraverseTree ¶
TraverseTree traverses the AST and calls the visitor function for each node