Documentation
¶
Overview ¶
Package symbols provides symbol extraction and caching.
Package symbols provides a unified symbol extraction service.
Package symbols provides symbol extraction using Tree-sitter for accurate AST parsing.
Index ¶
- type CacheEntry
- type Service
- func (s *Service) Close() error
- func (s *Service) ExtractSymbols(ctx context.Context, repoID int64, filePath, commitSHA string, code []byte, ...) ([]Symbol, error)
- func (s *Service) GetSymbolAtPosition(ctx context.Context, code []byte, language string, line, col int) (*Symbol, error)
- func (s *Service) InvalidateFile(ctx context.Context, repoID int64, filePath string) error
- func (s *Service) InvalidateRepo(ctx context.Context, repoID int64) error
- func (s *Service) IsLanguageSupported(language string) bool
- func (s *Service) SearchSymbols(ctx context.Context, repoID int64, query, kind string, limit int) ([]Symbol, error)
- func (s *Service) Stats(ctx context.Context, repoID int64) (map[string]any, error)
- func (s *Service) SupportedLanguages() []string
- type Symbol
- type SymbolCache
- func (c *SymbolCache) Close() error
- func (c *SymbolCache) GetSymbols(ctx context.Context, repoID int64, filePath, commitSHA string) ([]Symbol, bool, error)
- func (c *SymbolCache) InvalidateFile(ctx context.Context, repoID int64, filePath string) error
- func (c *SymbolCache) InvalidateRepo(ctx context.Context, repoID int64) error
- func (c *SymbolCache) SearchSymbols(ctx context.Context, repoID int64, query string, kind string, limit int) ([]Symbol, error)
- func (c *SymbolCache) SetSymbols(ctx context.Context, repoID int64, filePath, commitSHA string, ...) error
- func (c *SymbolCache) Stats(ctx context.Context, repoID int64) (map[string]any, error)
- type TreeSitterService
- func (s *TreeSitterService) ExtractSymbols(ctx context.Context, code []byte, lang string) ([]Symbol, error)
- func (s *TreeSitterService) GetSymbolAtPosition(ctx context.Context, code []byte, lang string, line, col int) (*Symbol, error)
- func (s *TreeSitterService) IsSupported(lang string) bool
- func (s *TreeSitterService) SupportedLanguages() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheEntry ¶
CacheEntry represents a cached symbol with metadata.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides symbol extraction with caching.
func NewService ¶
NewService creates a new symbol service.
func NewServiceWithoutCache ¶
func NewServiceWithoutCache() *Service
NewServiceWithoutCache creates a symbol service without caching (useful for testing).
func (*Service) ExtractSymbols ¶
func (s *Service) ExtractSymbols( ctx context.Context, repoID int64, filePath, commitSHA string, code []byte, language string, ) ([]Symbol, error)
ExtractSymbols extracts symbols from code, using cache when available.
func (*Service) GetSymbolAtPosition ¶
func (s *Service) GetSymbolAtPosition( ctx context.Context, code []byte, language string, line, col int, ) (*Symbol, error)
GetSymbolAtPosition returns the symbol at a specific position.
func (*Service) InvalidateFile ¶
InvalidateFile invalidates cached symbols for a file.
func (*Service) InvalidateRepo ¶
InvalidateRepo invalidates all cached symbols for a repository.
func (*Service) IsLanguageSupported ¶
IsLanguageSupported checks if Tree-sitter supports a language.
func (*Service) SearchSymbols ¶
func (s *Service) SearchSymbols( ctx context.Context, repoID int64, query, kind string, limit int, ) ([]Symbol, error)
SearchSymbols searches for symbols in a repository's cache.
func (*Service) SupportedLanguages ¶
SupportedLanguages returns the list of supported languages.
type Symbol ¶
type Symbol struct {
Name string `json:"name"`
Kind string `json:"kind"` // function, class, method, struct, interface, etc.
Line int `json:"line"`
Column int `json:"column"`
EndLine int `json:"endLine,omitempty"`
EndColumn int `json:"endColumn,omitempty"`
Signature string `json:"signature,omitempty"`
Parent string `json:"parent,omitempty"`
FilePath string `json:"filePath,omitempty"`
}
Symbol represents a code symbol (function, class, method, etc.)
type SymbolCache ¶
type SymbolCache struct {
// contains filtered or unexported fields
}
SymbolCache provides SQLite-based caching for extracted symbols.
func NewSymbolCache ¶
func NewSymbolCache(cacheDir string) (*SymbolCache, error)
NewSymbolCache creates a new symbol cache with the specified cache directory.
func (*SymbolCache) Close ¶
func (c *SymbolCache) Close() error
Close closes all database connections.
func (*SymbolCache) GetSymbols ¶
func (c *SymbolCache) GetSymbols( ctx context.Context, repoID int64, filePath, commitSHA string, ) ([]Symbol, bool, error)
GetSymbols retrieves cached symbols for a file.
func (*SymbolCache) InvalidateFile ¶
InvalidateFile removes cached symbols for a file.
func (*SymbolCache) InvalidateRepo ¶
func (c *SymbolCache) InvalidateRepo(ctx context.Context, repoID int64) error
InvalidateRepo clears all cached symbols for a repository.
func (*SymbolCache) SearchSymbols ¶
func (c *SymbolCache) SearchSymbols( ctx context.Context, repoID int64, query string, kind string, limit int, ) ([]Symbol, error)
SearchSymbols searches for symbols by name across all files in a repo.
func (*SymbolCache) SetSymbols ¶
func (c *SymbolCache) SetSymbols( ctx context.Context, repoID int64, filePath, commitSHA string, symbols []Symbol, ) error
SetSymbols stores symbols in the cache.
type TreeSitterService ¶
type TreeSitterService struct {
// contains filtered or unexported fields
}
TreeSitterService provides AST-based symbol extraction.
func NewTreeSitterService ¶
func NewTreeSitterService() *TreeSitterService
NewTreeSitterService creates a new Tree-sitter service with supported languages.
func (*TreeSitterService) ExtractSymbols ¶
func (s *TreeSitterService) ExtractSymbols( ctx context.Context, code []byte, lang string, ) ([]Symbol, error)
ExtractSymbols extracts symbols from source code using Tree-sitter.
func (*TreeSitterService) GetSymbolAtPosition ¶
func (s *TreeSitterService) GetSymbolAtPosition( ctx context.Context, code []byte, lang string, line, col int, ) (*Symbol, error)
GetSymbolAtPosition returns the symbol at a specific line and column.
func (*TreeSitterService) IsSupported ¶
func (s *TreeSitterService) IsSupported(lang string) bool
IsSupported checks if a language has Tree-sitter support.
func (*TreeSitterService) SupportedLanguages ¶
func (s *TreeSitterService) SupportedLanguages() []string
SupportedLanguages returns the list of languages with Tree-sitter support.