treesitter

package
v1.164.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentProcessor

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

DocumentProcessor uses tree-sitter to build syntax trees for source files and produce semantically aligned chunks (e.g., whole functions) while still respecting a maximum chunk size where possible.

NOTE: To keep the initial implementation minimal, this currently supports Go source files via the golang grammar. The design is intentionally generic so we can add more languages incrementally.

The processor is thread-safe: it creates a new parser for each Process() call since the underlying tree-sitter C library is not thread-safe.

func NewDocumentProcessor

func NewDocumentProcessor(chunkSize, chunkOverlap int, respectWordBoundaries bool) *DocumentProcessor

NewDocumentProcessor creates a new document processor instance with a language mapping that can be expanded over time. Falls back to text chunking for unsupported file types.

func (*DocumentProcessor) Process

func (p *DocumentProcessor) Process(ctx context.Context, path string, content []byte) ([]chunk.Chunk, error)

Process implements chunk.DocumentProcessor.

Jump to

Keyboard shortcuts

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