Documentation
¶
Overview ¶
Package index provides a unified code indexer with signature-based lookup, inspired by ATLANTIS's multi-tier code retrieval approach.
Key features: - Fast O(1) lookup of functions, classes, and methods - Signature-based matching (partial name, parameter patterns) - Cross-file reference resolution - Definition-usage linking - LRU caching for performance - Glob pattern matching for bulk queries
Index ¶
- Constants
- type Indexer
- func (idx *Indexer) AddReference(symbolID string, ref Reference)
- func (idx *Indexer) AddSymbol(sym *Symbol)
- func (idx *Indexer) Clear()
- func (idx *Indexer) FindDefinition(filePath string, line int, name string) *Symbol
- func (idx *Indexer) FindUsages(symbolID string) []Reference
- func (idx *Indexer) GetAllClasses() []*Symbol
- func (idx *Indexer) GetAllFunctions() []*Symbol
- func (idx *Indexer) GetByName(name string) []*Symbol
- func (idx *Indexer) GetClass(name string) *Symbol
- func (idx *Indexer) GetFunction(name string) []*Symbol
- func (idx *Indexer) GetMethod(className, methodName string) *Symbol
- func (idx *Indexer) GetReferences(symbolID string) []Reference
- func (idx *Indexer) GetSymbol(id string) *Symbol
- func (idx *Indexer) GetSymbolsInFile(filePath string) []*Symbol
- func (idx *Indexer) Search(query *SearchQuery) []*SearchResult
- func (idx *Indexer) Stats() map[string]int
- type Reference
- type SearchQuery
- type SearchResult
- type Symbol
- type SymbolType
Constants ¶
const ( SymbolFunction = constants.SymbolFunction SymbolMethod = constants.SymbolMethod SymbolClass = constants.SymbolClass SymbolInterface = constants.SymbolInterface SymbolVariable = constants.SymbolVariable SymbolConstant = constants.SymbolConstant SymbolProperty = constants.SymbolProperty SymbolParameter = constants.SymbolParameter )
Re-export SymbolType constants for backward compatibility
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer provides fast symbol lookup and cross-reference
func (*Indexer) AddReference ¶
AddReference adds a reference to a symbol
func (*Indexer) FindDefinition ¶
FindDefinition finds the definition of a symbol referenced at a location
func (*Indexer) FindUsages ¶
FindUsages finds all usages of a symbol
func (*Indexer) GetAllClasses ¶
GetAllClasses returns all indexed classes
func (*Indexer) GetAllFunctions ¶
GetAllFunctions returns all indexed functions
func (*Indexer) GetFunction ¶
GetFunction retrieves functions by name
func (*Indexer) GetReferences ¶
GetReferences retrieves all references to a symbol
func (*Indexer) GetSymbolsInFile ¶
GetSymbolsInFile retrieves all symbols in a file
func (*Indexer) Search ¶
func (idx *Indexer) Search(query *SearchQuery) []*SearchResult
Search performs a search query against the index
type Reference ¶
type Reference struct {
FilePath string `json:"file_path"`
Line int `json:"line"`
Column int `json:"column"`
Context string `json:"context,omitempty"` // Surrounding code
RefType string `json:"ref_type"` // call, assignment, import, etc.
}
Reference represents a usage of a symbol
type SearchQuery ¶
type SearchQuery struct {
Name string // Exact or partial name
NamePattern string // Regex pattern for name
Type SymbolType // Filter by type
ClassName string // Filter by class
FilePath string // Filter by file
FilePattern string // Glob pattern for files
Language string // Filter by language
HasParameter string // Has parameter matching this name
ReturnType string // Filter by return type
Limit int // Max results (0 = unlimited)
}
SearchQuery represents a search query
type SearchResult ¶
type SearchResult struct {
Symbol *Symbol `json:"symbol"`
Score float64 `json:"score"` // Match quality score
MatchedBy string `json:"matched_by"` // What matched (name, signature, etc.)
}
SearchResult represents a search result
type Symbol ¶
type Symbol struct {
ID string `json:"id"` // Unique identifier
Name string `json:"name"` // Symbol name
Type SymbolType `json:"type"`
FilePath string `json:"file_path"`
Line int `json:"line"`
Column int `json:"column"`
EndLine int `json:"end_line"`
EndColumn int `json:"end_column"`
// For functions/methods
Signature string `json:"signature,omitempty"` // Full signature
Parameters []string `json:"parameters,omitempty"` // Parameter names
ParamTypes []string `json:"param_types,omitempty"` // Parameter types
ReturnType string `json:"return_type,omitempty"`
// For methods/properties
ClassName string `json:"class_name,omitempty"`
Visibility string `json:"visibility,omitempty"` // public/private/protected
IsStatic bool `json:"is_static,omitempty"`
// Metadata
Language string `json:"language"`
DocComment string `json:"doc_comment,omitempty"`
Annotations []string `json:"annotations,omitempty"`
// References
References []Reference `json:"references,omitempty"`
}
Symbol represents an indexed code symbol
type SymbolType ¶
type SymbolType = constants.SymbolType
SymbolType represents the type of a code symbol Re-exported from pkg/sources/constants for backward compatibility