ts

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ts is the shared tree-sitter parse + capture helper used by per-language analyzers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(
	ctx context.Context,
	psr *treesitter.Parser,
	dirFS fs.FS,
	path string,
) (*treesitter.Tree, []byte, error)

Parse reads path from dirFS and parses it with psr, returning the syntax tree and the file contents.

func Query

Query compiles query for language and returns the compiled query together with a fresh query cursor.

Types

type CapturePair

type CapturePair struct {
	CaptureName string
	NodeStr     string
	StartRow    uint
	StartCol    uint
	EndRow      uint
	EndCol      uint
}

CapturePair is a single tree-sitter capture: its name, text, and source span.

func ProcessCaptures

func ProcessCaptures(
	ctx context.Context,
	match *treesitter.QueryMatch,
	captureNames []string,
	text []byte,
) []CapturePair

ProcessCaptures converts a single match's captures into CapturePairs.

func ProcessMatches

func ProcessMatches(
	ctx context.Context,
	matches treesitter.QueryMatches,
	captureNames []string,
	text []byte,
) []CapturePair

ProcessMatches flattens all matches into a single slice of CapturePair.

Jump to

Keyboard shortcuts

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