tree

package
v0.0.0-...-685dc72 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadPath = errors.New("invalid path")
)

Functions

func FixLineColumn

func FixLineColumn(n Node, source []byte)

FixLineColumn populates the Line and Column of nodes that only have Index set.

Types

type Key

type Key string

Key is used to differentiate leaves describing the start and end of where a key starts and where a value starts.

type Leaf

type Leaf struct {
	Marker
}

func (Leaf) Get

func (k Leaf) Get(ctx path.ContextPath) (Node, error)

type MapNode

type MapNode struct {
	Marker
	Children map[string]Node
	Keys     map[string]Leaf
}

func (MapNode) Get

func (m MapNode) Get(cxt path.ContextPath) (Node, error)

type Marker

type Marker struct {
	StartP *Pos
	EndP   *Pos
}

Markers are composed of information regarding the start and end of where a Node exists in its source.

func MarkerFromIndices

func MarkerFromIndices(start, end int64) Marker

func (Marker) End

func (m Marker) End() (int64, int64)

func (Marker) GetMarker

func (marker Marker) GetMarker() Marker

func (Marker) Start

func (m Marker) Start() (int64, int64)

func (Marker) String

func (m Marker) String() string

type Node

type Node interface {
	Start() (int64, int64) // line, col
	End() (int64, int64)
	Get(cxt path.ContextPath) (Node, error)
	GetMarker() Marker
	// contains filtered or unexported methods
}

Node is generic representation of a json or yaml node.

type Pos

type Pos struct {
	Index  int64
	Line   int64
	Column int64
}

Pos represents a single location in a string.

type SliceNode

type SliceNode struct {
	Marker
	Children []Node
}

func (SliceNode) Get

func (s SliceNode) Get(ctx path.ContextPath) (Node, error)

Jump to

Keyboard shortcuts

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