Documentation ¶
Index ¶
- Variables
- func AsNumber[T NumberValue](v T) json.Number
- func Walk(n Node, visitor func(n Node) (Node, Diagnostics, error)) (Node, Diagnostics, error)
- type ArrayNode
- type BooleanNode
- type Diagnostic
- type Diagnostics
- type Node
- type NullNode
- type NumberNode
- type NumberValue
- type ObjectNode
- type ObjectPropertyDef
- type Scalar
- type StringNode
- type Syntax
- type Trivia
Constants ¶
This section is empty.
Variables ¶
var NoSyntax = noSyntax(0)
Functions ¶
func AsNumber ¶
func AsNumber[T NumberValue](v T) json.Number
AsNumber converts the input value to a json.Number.
func Walk ¶ added in v0.6.0
func Walk(n Node, visitor func(n Node) (Node, Diagnostics, error)) (Node, Diagnostics, error)
Walk recursively walks the tree rooted at the given node. The visitor is called after the Node's descendants have been walked (i.e. visitation is post-order).
Types ¶
type ArrayNode ¶ added in v0.5.5
type ArrayNode struct {
// contains filtered or unexported fields
}
A ArrayNode represents an array of nodes.
func ArraySyntax ¶ added in v0.5.5
ArraySyntax creates a new array node with the given elements and associated syntax.
type BooleanNode ¶
type BooleanNode struct {
// contains filtered or unexported fields
}
A BooleanNode represents a boolean literal.
func Boolean ¶
func Boolean(value bool) *BooleanNode
Boolean creates a new boolean literal node with the given value.
func BooleanSyntax ¶
func BooleanSyntax(syntax Syntax, value bool) *BooleanNode
BooleanSyntax creates a new boolean literal node with the given value and associated syntax.
func (*BooleanNode) GoString ¶ added in v0.5.5
func (n *BooleanNode) GoString() string
func (*BooleanNode) String ¶
func (n *BooleanNode) String() string
func (*BooleanNode) Value ¶
func (n *BooleanNode) Value() bool
Value returns the boolean literal's value.
type Diagnostic ¶
type Diagnostic struct { hcl.Diagnostic Path string }
A Diagnostic represents a warning or an error to be presented to the user.
func Error ¶
func Error(rng *hcl.Range, summary, path string) *Diagnostic
Error creates a new error-level diagnostic from the given subject, summary, and detail.
func NodeError ¶
func NodeError(node Node, summary string) *Diagnostic
NodeError creates a new error-level diagnostic from the given node, summary, and detail. If the node is non-nil, the diagnostic will be associated with the range of its associated syntax, if any.
type Diagnostics ¶
type Diagnostics []*Diagnostic
Diagnostics is a list of diagnostics.
func (Diagnostics) Error ¶
func (d Diagnostics) Error() string
Error implements the error interface so that Diagnostics values may interoperate with APIs that use errors.
func (*Diagnostics) Extend ¶
func (d *Diagnostics) Extend(diags ...*Diagnostic)
Extend appends the given list of diagnostics to the list.
func (Diagnostics) HasErrors ¶
func (d Diagnostics) HasErrors() bool
HasErrors returns true if the list of diagnostics contains any error-level diagnostics.
type Node ¶
type Node interface { fmt.Stringer fmt.GoStringer Syntax() Syntax // contains filtered or unexported methods }
A Node represents a single node in an object tree.
type NullNode ¶
type NullNode struct {
// contains filtered or unexported fields
}
A NullNode represents a null literal.
func NullSyntax ¶
NullSyntax creates a new null literal node with associated syntax.
type NumberNode ¶
type NumberNode struct {
// contains filtered or unexported fields
}
A NumberNode represents a number literal.
func Number ¶
func Number[T NumberValue](value T) *NumberNode
Number creates a new number literal node with the given value.
func NumberSyntax ¶
func NumberSyntax[T NumberValue](syntax Syntax, value T) *NumberNode
NumberSyntax creates a new number literal node with the given value and associated syntax.
func (*NumberNode) GoString ¶ added in v0.5.5
func (n *NumberNode) GoString() string
func (*NumberNode) String ¶
func (n *NumberNode) String() string
func (*NumberNode) Value ¶
func (n *NumberNode) Value() json.Number
Value returns the number literal's value.
type NumberValue ¶
type NumberValue interface { int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr | float32 | float64 | json.Number }
NumberValue describes the set of types that can be represented as a number.
type ObjectNode ¶
type ObjectNode struct {
// contains filtered or unexported fields
}
An ObjectNode represents an object. An object is a list of key-value pairs where the keys are string literals and the values are arbitrary nodes.
func Object ¶
func Object(entries ...ObjectPropertyDef) *ObjectNode
Object creates a new object node with the given properties.
func ObjectSyntax ¶
func ObjectSyntax(syntax Syntax, entries ...ObjectPropertyDef) *ObjectNode
ObjectSyntax creates a new object node with the given properties and associated syntax.
func (*ObjectNode) GoString ¶ added in v0.5.5
func (n *ObjectNode) GoString() string
func (*ObjectNode) Index ¶
func (n *ObjectNode) Index(i int) ObjectPropertyDef
Index returns the i'th property of the object.
func (*ObjectNode) Len ¶
func (n *ObjectNode) Len() int
Len returns the number of properties in the object.
func (*ObjectNode) SetIndex ¶ added in v0.5.5
func (n *ObjectNode) SetIndex(i int, prop ObjectPropertyDef)
SetIndex sets the i'th property of the object.
func (*ObjectNode) String ¶
func (n *ObjectNode) String() string
type ObjectPropertyDef ¶
type ObjectPropertyDef struct { Syntax Syntax // The syntax associated with the property, if any. Key *StringNode // The name of the property. Value Node // The value of the property. }
An ObjectPropertyDef represents a property definition in an object.
func ObjectProperty ¶
func ObjectProperty(key *StringNode, value Node) ObjectPropertyDef
ObjectProperty creates a new object property definition with the given key and value.
func ObjectPropertySyntax ¶
func ObjectPropertySyntax(syntax Syntax, key *StringNode, value Node) ObjectPropertyDef
ObjectPropertySyntax creates a new object property definition with the given key, value, and associated syntax.
func (ObjectPropertyDef) GoString ¶ added in v0.5.5
func (d ObjectPropertyDef) GoString() string
type StringNode ¶
type StringNode struct {
// contains filtered or unexported fields
}
A StringNode represents a string literal.
func String ¶
func String(value string) *StringNode
String creates a new string literal node with the given value.
func StringSyntax ¶
func StringSyntax(syntax Syntax, value string) *StringNode
String creates a new string literal node with the given value and associated syntax.
func (*StringNode) GoString ¶ added in v0.5.5
func (n *StringNode) GoString() string
func (*StringNode) String ¶
func (n *StringNode) String() string
String returns the string literal's value.
func (*StringNode) Value ¶
func (n *StringNode) Value() string
Value returns the string literal's value.
type Syntax ¶
type Syntax interface { Range() *hcl.Range Path() string }