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
- func IndexedSource(file string) bool
- func ReaderWaitExpired(f *protocol.Fault) bool
- 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) GraphOnDemand(ctx context.Context, id protocol.WorktreeID, root string, ...) (protocol.CodeIndexGraphGraphPage, error)
- func (s *Service) Observed(id protocol.WorktreeID, paths []string)
- func (s *Service) OutlineOnDemand(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)
- func (s *Service) SearchOnDemand(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-v2:gotreesitter:v0.57.0:embedded-1:source-1:references-2:budget-64m")
Fingerprint identifies this engine's extraction rules in files.fingerprint. Records written under any other rules are parsed again.
Functions ¶
func IndexedSource ¶ added in v0.2.4
IndexedSource reports whether a path can contribute declarations and references. Unknown names still get a shebang check when discovered.
func ReaderWaitExpired ¶ added in v0.2.6
ReaderWaitExpired identifies only the live scan budget exhausted waiting for a file reader, not the operation deadline or another busy fault.
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.
func (*Parser) Parse ¶
Parse extracts the declarations, references and imports of one source. It fails only when ctx is cancelled.
func (*Parser) ParseIndexed ¶ added in v0.2.4
ParseIndexed extracts code only, returning file metadata for excluded paths.
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) GraphOnDemand ¶ added in v0.2.4
func (s *Service) GraphOnDemand(ctx context.Context, id protocol.WorktreeID, root string, query protocol.CodeIndexGraph) (protocol.CodeIndexGraphGraphPage, error)
GraphOnDemand builds a query-local graph from selected source and lexical matches. The same resolver supplies positions, ambiguity and confidence.
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) OutlineOnDemand ¶ added in v0.2.4
func (s *Service) OutlineOnDemand(ctx context.Context, id protocol.WorktreeID, root, path string) (protocol.CodeIndexOutline, error)
OutlineOnDemand parses exactly one file and retains its content revision for subsequent range reads, without opening a derived database.
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.
func (*Service) SearchOnDemand ¶ added in v0.2.4
func (s *Service) SearchOnDemand(ctx context.Context, id protocol.WorktreeID, root string, query protocol.CodeIndexSearch) (protocol.CodeIndexSearchPage, error)
SearchOnDemand lexically selects candidate files before parsing. The same bounded full-text ranking used by persistent indexes runs in memory.
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.