Documentation
¶
Overview ¶
Package index defines the indexing contract and the data types that flow from a language backend into the store. Backends parse source on disk and push symbols, references, edges and routes into a Sink.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Registry = []Indexer{ GoNative{}, TreeSitter{}, }
Registry holds the available backends in priority order (highest fidelity first). GoNative owns Go (precise); TreeSitter covers curated non-Go languages (heuristic) and skips Go.
Functions ¶
func SourceSignature ¶
SourceSignature computes a content hash over all source files codenav would index in a repo (Go files plus curated tree-sitter languages). It is used to skip re-indexing when nothing has changed. The signature is order-independent and sensitive to file content, additions and deletions.
Types ¶
type Edge ¶
type Edge struct {
FromQName string
ToQName string
Kind string // CALLS|IMPORTS|IMPLEMENTS|CROSS_CALLS
Confidence float64 // 1.0 for precise, <1.0 for heuristic
}
Edge is a resolved relationship between two symbols, keyed by qname so the store can map both ends to symbol ids after all symbols are inserted.
type Fidelity ¶
type Fidelity string
Fidelity describes how trustworthy a backend's output is.
const ( // Precise output comes from a type-resolved analysis (Go via x/tools). Precise Fidelity = "precise" // Heuristic output comes from syntactic parsing plus name/import // resolution (tree-sitter backends). Heuristic Fidelity = "heuristic" // FTSOnly means a file is only full-text searchable, no symbols. FTSOnly Fidelity = "fts" )
type GoNative ¶
type GoNative struct{}
GoNative is the precise Go backend. It uses go/packages for type-resolved symbols and references, and a CHA call graph for precise CALLS edges.
Qualified names use the import path so they are globally meaningful and line up across repositories (enabling Go cross-repo linking in M2):
<import-path>.<Name> for funcs, types, vars, consts <import-path>.<Recv>.<Method> for methods
type Indexer ¶
type Indexer interface {
Name() string
Fidelity() Fidelity
// CanHandle reports whether this backend should run for the repo
// (e.g. GoNative when a go.mod is present).
CanHandle(RepoScan) bool
Index(ctx context.Context, scan RepoScan, sink Sink) error
}
Indexer is a language backend.
type Reference ¶
type Reference struct {
ToQName string // qname of the referenced symbol (may resolve later)
File string // repo-relative path of the use site
Line int
Col int
Role string // call|read|write|import|impl
}
Reference is a use-site of a symbol (call, read, import, ...).
type Sink ¶
type Sink interface {
File(FileRec) error
Symbol(Symbol) error
Reference(Reference) error
Edge(Edge) error
Route(Route) error
}
Sink receives everything a backend extracts. Implementations batch and persist; calls are not safe for concurrent use unless documented otherwise.
type Symbol ¶
type Symbol struct {
QName string // <project>.<modpath>.<name> — stable, cross-repo for Go
Name string // bare name, for search and name-based resolution
Kind string // func|method|type|var|const|iface|field|...
File string // repo-relative path
Signature string
Doc string
StartLine, StartCol int
EndLine, EndCol int
}
Symbol is a definition (function, method, type, var, const, ...).
type TreeSitter ¶
type TreeSitter struct{}
TreeSitter is the heuristic multi-language backend. It parses non-Go source with the pure-Go gotreesitter runtime, extracts definitions and call sites via bundled tags.scm queries, and resolves call sites to definitions with a name/scope cascade (see resolve.go). Fidelity is Heuristic — unlike GoNative, edges are name-resolved, not type-resolved.
Only a curated, validated set of languages is enabled (gotreesitter ships 200+ grammars but tags-query quality varies; these were verified to extract both definitions and references). Go is intentionally excluded — GoNative owns it.
func (TreeSitter) CanHandle ¶
func (TreeSitter) CanHandle(RepoScan) bool
CanHandle always returns true: the backend contributes whatever curated non-Go files it finds, and emits nothing for repos without them.
func (TreeSitter) Fidelity ¶
func (TreeSitter) Fidelity() Fidelity
func (TreeSitter) Name ¶
func (TreeSitter) Name() string