tspool

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tspool provides tree-sitter parsers for concurrent parsing.

This package centralizes parser management to:

  • Provide consistent parser creation across components
  • Ensure thread-safe language initialization

Note: Parser pooling is disabled due to tree-sitter cancellation flag issues. When a context is cancelled during ParseCtx, the parser's internal cancel flag is set but not properly reset, causing subsequent parses to fail with "operation limit was hit". Creating fresh parsers avoids this issue.

Thread-safety: Parsers returned by Get are NOT safe for concurrent use. Each goroutine must Get its own parser or use the Parse helper.

Index

Constants

View Source
const MaxTreeDepth = 1000

MaxTreeDepth is the maximum recursion depth when walking AST trees.

Variables

This section is empty.

Functions

func Get

func Get(lang domain.Language) *sitter.Parser

Get returns a parser for the given language. The returned parser is NOT safe for concurrent use. Caller MUST call parser.Close() when done to free resources.

func GetLanguage

func GetLanguage(lang domain.Language) *sitter.Language

GetLanguage returns the tree-sitter language for the given domain language.

func Parse

func Parse(ctx context.Context, lang domain.Language, source []byte) (*sitter.Tree, error)

Parse parses source using a fresh parser. Caller MUST call tree.Close() to free resources.

Types

This section is empty.

Jump to

Keyboard shortcuts

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