dump

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpLispExpression

func DumpLispExpression(expr pm.Expression, w io.Writer, opts LispOptions) error

DumpLispExpression pretty-prints a pm.Expression as a Lisp S-expression.

func DumpVerboseAST

func DumpVerboseAST(node *sitter.Node, content []byte, w io.Writer)

DumpVerboseAST writes a detailed AST with line/col, byte offsets, and flags.

Types

type Dumper

type Dumper interface {
	Dump(tree *sitter.Tree, source []byte, w io.Writer, options Options) error
}

Dumper is the interface that all tree dumpers must implement

func NewDumper

func NewDumper(format Format) Dumper

NewDumper creates a new tree dumper for the specified format

type Format

type Format string

Format represents a tree output format type

const (
	// FormatText is the enhanced text output format
	FormatText Format = "text"
	// FormatXML is the XML output format
	FormatXML Format = "xml"
	// FormatJSON is the JSON output format
	FormatJSON Format = "json"
	// FormatYAML is the YAML output format
	FormatYAML Format = "yaml"
)

type JSONDumper

type JSONDumper struct{}

JSONDumper implements the JSON format dumper

func (*JSONDumper) Dump

func (d *JSONDumper) Dump(tree *sitter.Tree, source []byte, w io.Writer, options Options) error

Dump outputs the tree in JSON format

type LispOptions

type LispOptions struct {
	// Indent is the indentation string per nesting level. Defaults to two spaces if empty.
	Indent string
	// Compact prints a single-line representation (delegates to expr.String()).
	Compact bool
}

type NodeJSON

type NodeJSON struct {
	Type      string                 `json:"type"`
	Position  string                 `json:"pos"`             // Format: "startLine,startCol-endLine,endCol"
	Bytes     string                 `json:"bytes,omitempty"` // Optional
	IsNamed   bool                   `json:"is_named,omitempty"`
	IsMissing bool                   `json:"is_missing,omitempty"`
	IsExtra   bool                   `json:"is_extra,omitempty"`
	HasError  bool                   `json:"has_error,omitempty"`
	Content   string                 `json:"content,omitempty"`
	Fields    map[string][]*NodeJSON `json:"fields,omitempty"`
	Children  []*NodeJSON            `json:"children,omitempty"`
}

NodeJSON represents a tree node in JSON format

type NodeYAML

type NodeYAML struct {
	Type     string                 `yaml:"type"`
	Position string                 `yaml:"pos"`             // Format: "startLine,startCol-endLine,endCol"
	Bytes    string                 `yaml:"bytes,omitempty"` // Format: "startByte-endByte" (optional)
	Named    bool                   `yaml:"named,omitempty"`
	Missing  bool                   `yaml:"missing,omitempty"`
	Extra    bool                   `yaml:"extra,omitempty"`
	HasError bool                   `yaml:"has_error,omitempty"`
	Content  string                 `yaml:"content,omitempty"`
	Fields   map[string][]*NodeYAML `yaml:"fields,omitempty"`
	Children []*NodeYAML            `yaml:"children,omitempty"`
}

NodeYAML represents a tree node in YAML format

type Options

type Options struct {
	ShowBytes      bool
	ShowContent    bool
	ShowAttributes bool
	SkipWhitespace bool
}

Options contains settings for tree dumping

type TextDumper

type TextDumper struct{}

TextDumper implements the enhanced text format dumper

func (*TextDumper) Dump

func (d *TextDumper) Dump(tree *sitter.Tree, source []byte, w io.Writer, options Options) error

Dump outputs the tree in enhanced text format

type XMLDumper

type XMLDumper struct{}

XMLDumper implements the XML format dumper

func (*XMLDumper) Dump

func (d *XMLDumper) Dump(tree *sitter.Tree, source []byte, w io.Writer, options Options) error

Dump outputs the tree in XML format

type YAMLDumper

type YAMLDumper struct{}

YAMLDumper implements the YAML format dumper

func (*YAMLDumper) Dump

func (d *YAMLDumper) Dump(tree *sitter.Tree, source []byte, w io.Writer, options Options) error

Dump outputs the tree in YAML format

Jump to

Keyboard shortcuts

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