Documentation
¶
Overview ¶
Package codeindex extracts declarations and references with the pinned gotreesitter grammars and serves bounded queries over a rebuildable index.
Index ¶
- Constants
- Variables
- func Candidate(file string) bool
- func Hash(source string) string
- type Capabilities
- type Parsed
- type Parser
- type Range
- type Scope
- type Service
- func (s *Service) Changed(id protocol.WorktreeID, path *string)
- func (s *Service) Close()
- func (s *Service) Configure(enabled bool)
- func (s *Service) Graph(ctx context.Context, id protocol.WorktreeID, root string, ...) (protocol.CodeIndexGraphGraphPage, error)
- func (s *Service) Observed(id protocol.WorktreeID, paths []string)
- func (s *Service) Outline(ctx context.Context, id protocol.WorktreeID, root, path string) (protocol.CodeIndexOutline, error)
- func (s *Service) Remove(id protocol.WorktreeID) error
- func (s *Service) Search(ctx context.Context, id protocol.WorktreeID, root string, ...) (protocol.CodeIndexSearchPage, error)
- type Status
- type Symbol
- type Usage
- type Watch
Constants ¶
const ( StatusParsed = protocol.CodeIndexStatusParsed StatusUnsupported = protocol.CodeIndexStatusUnsupported StatusTooLarge = protocol.CodeIndexStatusTooLarge StatusInvalid = protocol.CodeIndexStatusInvalid StatusFailed = protocol.CodeIndexStatusFailed )
const MaxFileBytes = 1024 * 1024
MaxFileBytes is the largest source the index parses.
Variables ¶
var Fingerprint = Hash("code-index-v1:gotreesitter:v0.57.0:embedded-1:data-1:references-2")
Fingerprint identifies this engine's extraction rules in files.fingerprint. Records written under any other rules are parsed again.
Functions ¶
Types ¶
type Capabilities ¶
type Capabilities = protocol.CodeIndexCapabilities
type Parsed ¶
type Parsed struct {
Path string
Language string
Hash string
Status Status
Symbols []Symbol
References []Usage
Imports []string
Capabilities Capabilities
Partial bool
Truncated bool
}
Parsed is the indexable content of one file. Ranges keep UTF-8 coordinates.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser extracts one file at a time. Compiled queries are shared by every parse.
type Range ¶
type Range = protocol.CodeIndexRange
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns the code indexes of a profile, one per worktree.
func (*Service) Changed ¶
func (s *Service) Changed(id protocol.WorktreeID, path *string)
Changed invalidates a worktree, moving an exactly known path to the front of its next reconcile.
func (*Service) Configure ¶
Configure enables or disables indexing. Disabling stops every query and closes the indexes; their files stay as a cache.
func (*Service) Graph ¶
func (s *Service) Graph(ctx context.Context, id protocol.WorktreeID, root string, query protocol.CodeIndexGraph) (protocol.CodeIndexGraphGraphPage, error)
Graph traces name-resolved references between indexed definitions.
func (*Service) Observed ¶
func (s *Service) Observed(id protocol.WorktreeID, paths []string)
Observed invalidates the walk for one batch and marks exactly named source files for content checks. Empty batches and root/unknown paths require a full check. A directory or ignore-rule change still invalidates the walk even if none of its paths are index candidates.
func (*Service) Outline ¶
func (s *Service) Outline(ctx context.Context, id protocol.WorktreeID, root, path string) (protocol.CodeIndexOutline, error)
Outline refreshes one file and returns its declarations.
func (*Service) Remove ¶
func (s *Service) Remove(id protocol.WorktreeID) error
Remove deletes the derived cache of a removed worktree.
func (*Service) Search ¶
func (s *Service) Search(ctx context.Context, id protocol.WorktreeID, root string, query protocol.CodeIndexSearch) (protocol.CodeIndexSearchPage, error)
Search finds indexed declarations by name and full-text terms.
type Status ¶
type Status = protocol.CodeIndexStatus
type Symbol ¶
type Symbol = protocol.CodeIndexSymbol
type Usage ¶
type Usage struct {
Name string
Kind string
Line uint32
Column uint32
Start uint32
// Receiver marks a name written through self or this.
Receiver bool
// Parsed references in the same declaration share a read-only Scope.
Scope *Scope
}
Usage is one reference occurrence. Bytes and columns are UTF-8 offsets.
type Watch ¶
type Watch func(ctx context.Context, root string, worktree protocol.WorktreeID) (link.Subscription, error)
Watch subscribes to changes of one worktree root. Its owner delivers every batch to Observed (empty for unknown changes) before waking the subscription. Successful wakes may coalesce; subscription errors report loss of the watch.