parser

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VisualizeLanguageTree

func VisualizeLanguageTree(tree *LanguageTree) string

Types

type File

type File struct {
	Type file.Type

	Tree *LanguageTree

	// Content
	Src utils.Buffer
}

func Parse

func Parse(content []byte, typ file.Type) (*File, error)

func (*File) FindCaptures

func (f *File) FindCaptures(language, pattern string, captures ...string) (treesitter.CaptureSlice, error)

func (*File) NodeMatchesCapture

func (f *File) NodeMatchesCapture(language, pattern, capture string, node *ts.Node) bool

func (*File) Query

func (f *File) Query(pattern string) (*ts.Query, *ts.QueryError)

func (*File) SetContent

func (f *File) SetContent(src []byte) error

Set the file contents.

func (*File) Update

func (f *File) Update(start, end ts.Point, src []byte) error

Update part of file contents

type LanguageTree

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

func (LanguageTree) FindCaptures

func (t LanguageTree) FindCaptures(language, pattern string, source []byte, captures ...string) (treesitter.CaptureSlice, error)

func (LanguageTree) GetLanguageTrees

func (t LanguageTree) GetLanguageTrees(language string) []*LanguageTree

Get all trees for a particular language

func (*LanguageTree) GetLanguageTreesWithNode

func (t *LanguageTree) GetLanguageTreesWithNode(language string, node *ts.Node) []*LanguageTree

Find all trees of a given language that includes the node

func (*LanguageTree) InRange

func (t *LanguageTree) InRange(r ts.Range) bool

func (*LanguageTree) Root

func (t *LanguageTree) Root() *ts.Node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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