treesitter

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQueryNotFound error = errors.New("query not found")

Functions

func CalculateEdit

func CalculateEdit(start, end ts.Point, oldSrc []byte, newSrc []byte) *ts.InputEdit

Calculate a treesitter InputEdit object.

func CalculateNewEndPoint

func CalculateNewEndPoint(start ts.Point, src []byte) ts.Point

Calculate a new endpoint

func FirstNamedChild

func FirstNamedChild(node *ts.Node) *ts.Node

func FirstNamedChildOfKind

func FirstNamedChildOfKind(node *ts.Node, kind string) *ts.Node

func FreeQueryCache added in v0.0.4

func FreeQueryCache()

func GetInjectionQuery added in v0.0.4

func GetInjectionQuery(lang language.Identifier) (*ts.Query, error)

func GetQuery added in v0.0.4

func GetQuery(langID language.Identifier, name string) (*ts.Query, error)

func GetRowByte

func GetRowByte(row uint, src []byte) uint

Get the byte count at an specific row.

func GetTagsQuery added in v0.0.4

func GetTagsQuery(lang language.Identifier) (*ts.Query, error)

func NamedChildOfKind

func NamedChildOfKind(node *ts.Node, kind string) *ts.Node

func PointInRange

func PointInRange(p ts.Point, r ts.Range) bool

Returns true if point p is inside range r

func PointToByteOffset

func PointToByteOffset(point ts.Point, src []byte) uint

Get the byte offset for a point.

func RangeOverlap

func RangeOverlap(a ts.Range, b ts.Range) bool

Returns true if range a and b overlaps. (calculated using point fields)

func RangeOverlapBytes

func RangeOverlapBytes(a ts.Range, b ts.Range) bool

Returns true if range a and b overlaps (calculated using byte fields)

func ReadQueryFromFile added in v0.0.4

func ReadQueryFromFile(lang *language.Language, name string) (string, error)

Read a query from file

Types

type Capture

type Capture struct {
	Name string
	Node ts.Node
}

type CaptureSlice

type CaptureSlice []Capture

func (CaptureSlice) At

func (captures CaptureSlice) At(position ts.Point) *ts.Node

Find a capture at a given position

func (CaptureSlice) In

func (captures CaptureSlice) In(r ts.Range) []*ts.Node

Find all captures in a given range

func (CaptureSlice) Name added in v0.0.4

func (captures CaptureSlice) Name(name ...string) CaptureSlice

Find all captures with a given name or names.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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