codeindex

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package codeindex extracts declarations and references with the pinned gotreesitter grammars and serves bounded queries over a rebuildable index.

Index

Constants

View Source
const MaxFileBytes = 1024 * 1024

MaxFileBytes is the largest source the index parses.

Variables

View Source
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

func Candidate

func Candidate(file string) bool

Candidate reports whether a path may hold an indexed language.

func Hash

func Hash(source string) string

Hash is the content revision of a source.

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.

func Omitted

func Omitted(file string, status Status) Parsed

Omitted describes a file the index holds no declarations for.

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

func (p *Parser) Parse(ctx context.Context, file, source string) (Parsed, error)

Parse extracts the declarations, references and imports of one source. It fails only when ctx is cancelled.

type Range

type Range = protocol.CodeIndexRange

type Scope

type Scope struct {
	Name      string
	Kind      string
	StartLine uint32
	EndLine   uint32
}

Scope is the innermost indexed declaration containing a reference.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service owns the code indexes of a profile, one per worktree.

func New

func New(profile string, watch Watch) *Service

New returns the enabled index service of a profile directory.

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) Close

func (s *Service) Close()

Close stops the service for good.

func (*Service) Configure

func (s *Service) Configure(enabled bool)

Configure enables or disables indexing. Disabling stops every query and closes the indexes; their files stay as a cache.

func (*Service) Graph

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL