Documentation ¶
Index ¶
- Variables
- func AllowMissingVariables(options *bindOptions)
- func ContainsEventuals(t Type) (containsOutputs, containsPromises bool)
- func ContainsOutputs(t Type) bool
- func ContainsPromises(t Type) bool
- func ExprNotConvertible(destType Type, expr Expression) *hcl.Diagnostic
- func GetCollectionTypes(collectionType Type, rng hcl.Range, strict bool) (Type, Type, hcl.Diagnostics)
- func GetObjectTypeAnnotation[T any](t *ObjectType) (T, bool)
- func HCLExpression(x Expression) hcl.Expression
- func IsConstType(t Type) bool
- func IsOptionalType(t Type) bool
- func MakeTraverser(t Type) hcl.TraverseIndex
- func SkipRangeTypechecking(options *bindOptions)
- func SourceOrderBody(body *hclsyntax.Body) []hclsyntax.Node
- func SourceOrderLess(a, b hcl.Range) bool
- func UnifyTypes(types ...Type) (safeType Type, unsafeType Type)
- func VisitExpressions(n BodyItem, pre, post ExpressionVisitor) hcl.Diagnostics
- type AnonymousFunctionExpression
- func (x *AnonymousFunctionExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *AnonymousFunctionExpression) Format(f fmt.State, c rune)
- func (x *AnonymousFunctionExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *AnonymousFunctionExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *AnonymousFunctionExpression) HasLeadingTrivia() bool
- func (x *AnonymousFunctionExpression) HasTrailingTrivia() bool
- func (x *AnonymousFunctionExpression) NodeTokens() syntax.NodeTokens
- func (x *AnonymousFunctionExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *AnonymousFunctionExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *AnonymousFunctionExpression) SyntaxNode() hclsyntax.Node
- func (x *AnonymousFunctionExpression) Type() Type
- func (x *AnonymousFunctionExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type Attribute
- func (a *Attribute) Format(f fmt.State, c rune)
- func (a *Attribute) GetLeadingTrivia() syntax.TriviaList
- func (a *Attribute) GetTrailingTrivia() syntax.TriviaList
- func (a *Attribute) HasLeadingTrivia() bool
- func (a *Attribute) HasTrailingTrivia() bool
- func (a *Attribute) SyntaxNode() hclsyntax.Node
- func (a *Attribute) Type() Type
- type BinaryOpExpression
- func (x *BinaryOpExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *BinaryOpExpression) Format(f fmt.State, c rune)
- func (x *BinaryOpExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *BinaryOpExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *BinaryOpExpression) HasLeadingTrivia() bool
- func (x *BinaryOpExpression) HasTrailingTrivia() bool
- func (x *BinaryOpExpression) LeftOperandType() Type
- func (x *BinaryOpExpression) NodeTokens() syntax.NodeTokens
- func (x *BinaryOpExpression) RightOperandType() Type
- func (x *BinaryOpExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *BinaryOpExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *BinaryOpExpression) SyntaxNode() hclsyntax.Node
- func (x *BinaryOpExpression) Type() Type
- func (x *BinaryOpExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type BindOption
- type Block
- type Body
- func (b *Body) Attribute(name string) (*Attribute, bool)
- func (b *Body) Blocks(typ string) []*Block
- func (b *Body) Format(f fmt.State, c rune)
- func (b *Body) GetLeadingTrivia() syntax.TriviaList
- func (b *Body) GetTrailingTrivia() syntax.TriviaList
- func (b *Body) HasLeadingTrivia() bool
- func (b *Body) HasTrailingTrivia() bool
- func (b *Body) SyntaxNode() hclsyntax.Node
- type BodyItem
- type BodyItemVisitor
- type ConditionalExpression
- func (x *ConditionalExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *ConditionalExpression) Format(f fmt.State, c rune)
- func (x *ConditionalExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *ConditionalExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *ConditionalExpression) HasLeadingTrivia() bool
- func (x *ConditionalExpression) HasTrailingTrivia() bool
- func (x *ConditionalExpression) NodeTokens() syntax.NodeTokens
- func (x *ConditionalExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *ConditionalExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *ConditionalExpression) SyntaxNode() hclsyntax.Node
- func (x *ConditionalExpression) Type() Type
- func (x *ConditionalExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type ConstType
- func (t *ConstType) AssignableFrom(src Type) bool
- func (t *ConstType) ConversionFrom(src Type) ConversionKind
- func (t *ConstType) Equals(other Type) bool
- func (t *ConstType) Pretty() pretty.Formatter
- func (t *ConstType) String() string
- func (*ConstType) SyntaxNode() hclsyntax.Node
- func (t *ConstType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type Constant
- type ConversionKind
- type Definition
- type EnumType
- func (t *EnumType) AssignableFrom(src Type) bool
- func (t *EnumType) ConversionFrom(src Type) ConversionKind
- func (t *EnumType) Equals(other Type) bool
- func (t *EnumType) Pretty() pretty.Formatter
- func (t *EnumType) String() string
- func (*EnumType) SyntaxNode() hclsyntax.Node
- func (t *EnumType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type ErrorExpression
- func (x *ErrorExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *ErrorExpression) Format(f fmt.State, c rune)
- func (x *ErrorExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *ErrorExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *ErrorExpression) HasLeadingTrivia() bool
- func (x *ErrorExpression) HasTrailingTrivia() bool
- func (x *ErrorExpression) NodeTokens() syntax.NodeTokens
- func (x *ErrorExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *ErrorExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *ErrorExpression) SyntaxNode() hclsyntax.Node
- func (x *ErrorExpression) Type() Type
- func (x *ErrorExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type Expression
- func BindExpression(syntax hclsyntax.Node, scope *Scope, tokens _syntax.TokenMap, ...) (Expression, hcl.Diagnostics)
- func BindExpressionText(source string, scope *Scope, initialPos hcl.Pos, opts ...BindOption) (Expression, hcl.Diagnostics)
- func IdentityVisitor(n Expression) (Expression, hcl.Diagnostics)
- func VisitExpression(n Expression, pre, post ExpressionVisitor) (Expression, hcl.Diagnostics)
- type ExpressionVisitor
- type ForExpression
- func (x *ForExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *ForExpression) Format(f fmt.State, c rune)
- func (x *ForExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *ForExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *ForExpression) HasLeadingTrivia() bool
- func (x *ForExpression) HasTrailingTrivia() bool
- func (x *ForExpression) NodeTokens() syntax.NodeTokens
- func (x *ForExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *ForExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *ForExpression) SyntaxNode() hclsyntax.Node
- func (x *ForExpression) Type() Type
- func (x *ForExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type Function
- type FunctionCallExpression
- func (x *FunctionCallExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *FunctionCallExpression) Format(f fmt.State, c rune)
- func (x *FunctionCallExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *FunctionCallExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *FunctionCallExpression) HasLeadingTrivia() bool
- func (x *FunctionCallExpression) HasTrailingTrivia() bool
- func (x *FunctionCallExpression) NodeTokens() syntax.NodeTokens
- func (x *FunctionCallExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *FunctionCallExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *FunctionCallExpression) SyntaxNode() hclsyntax.Node
- func (x *FunctionCallExpression) Type() Type
- func (x *FunctionCallExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type FunctionSignature
- type GenericFunctionSignature
- type IndexExpression
- func (x *IndexExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *IndexExpression) Format(f fmt.State, c rune)
- func (x *IndexExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *IndexExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *IndexExpression) HasLeadingTrivia() bool
- func (x *IndexExpression) HasTrailingTrivia() bool
- func (x *IndexExpression) KeyType() Type
- func (x *IndexExpression) NodeTokens() syntax.NodeTokens
- func (x *IndexExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *IndexExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *IndexExpression) SyntaxNode() hclsyntax.Node
- func (x *IndexExpression) Type() Type
- func (x *IndexExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type Keyword
- type ListType
- func (t *ListType) AssignableFrom(src Type) bool
- func (t *ListType) ConversionFrom(src Type) ConversionKind
- func (t *ListType) Equals(other Type) bool
- func (t *ListType) Pretty() pretty.Formatter
- func (t *ListType) String() string
- func (*ListType) SyntaxNode() hclsyntax.Node
- func (t *ListType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type LiteralValueExpression
- func (x *LiteralValueExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *LiteralValueExpression) Format(f fmt.State, c rune)
- func (x *LiteralValueExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *LiteralValueExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *LiteralValueExpression) HasLeadingTrivia() bool
- func (x *LiteralValueExpression) HasTrailingTrivia() bool
- func (x *LiteralValueExpression) NodeTokens() syntax.NodeTokens
- func (x *LiteralValueExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *LiteralValueExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *LiteralValueExpression) SyntaxNode() hclsyntax.Node
- func (x *LiteralValueExpression) Type() Type
- func (x *LiteralValueExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type MapType
- func (t *MapType) AssignableFrom(src Type) bool
- func (t *MapType) ConversionFrom(src Type) ConversionKind
- func (t *MapType) Equals(other Type) bool
- func (t *MapType) Pretty() pretty.Formatter
- func (t *MapType) String() string
- func (*MapType) SyntaxNode() hclsyntax.Node
- func (t *MapType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type ObjectConsExpression
- func (x *ObjectConsExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *ObjectConsExpression) Format(f fmt.State, c rune)
- func (x *ObjectConsExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *ObjectConsExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *ObjectConsExpression) HasLeadingTrivia() bool
- func (x *ObjectConsExpression) HasTrailingTrivia() bool
- func (x *ObjectConsExpression) NodeTokens() syntax.NodeTokens
- func (x *ObjectConsExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *ObjectConsExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *ObjectConsExpression) SyntaxNode() hclsyntax.Node
- func (x *ObjectConsExpression) Type() Type
- func (x *ObjectConsExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- func (x *ObjectConsExpression) WithType(updateType func(Type) *ObjectConsExpression) *ObjectConsExpression
- type ObjectConsItem
- type ObjectType
- func (t *ObjectType) Annotate(annotations ...interface{})
- func (t *ObjectType) AssignableFrom(src Type) bool
- func (t *ObjectType) ConversionFrom(src Type) ConversionKind
- func (t *ObjectType) Equals(other Type) bool
- func (t *ObjectType) Pretty() pretty.Formatter
- func (t *ObjectType) String() string
- func (*ObjectType) SyntaxNode() hclsyntax.Node
- func (t *ObjectType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type OpaqueType
- func (t *OpaqueType) AssignableFrom(src Type) bool
- func (t *OpaqueType) ConversionFrom(src Type) ConversionKind
- func (t *OpaqueType) Equals(other Type) bool
- func (t *OpaqueType) Pretty() pretty.Formatter
- func (t *OpaqueType) String() string
- func (*OpaqueType) SyntaxNode() hclsyntax.Node
- func (t *OpaqueType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type OutputType
- func (t *OutputType) AssignableFrom(src Type) bool
- func (t *OutputType) ConversionFrom(src Type) ConversionKind
- func (t *OutputType) Equals(other Type) bool
- func (t *OutputType) Pretty() pretty.Formatter
- func (t *OutputType) String() string
- func (*OutputType) SyntaxNode() hclsyntax.Node
- func (t *OutputType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type Parameter
- type PromiseType
- func (t *PromiseType) AssignableFrom(src Type) bool
- func (t *PromiseType) ConversionFrom(src Type) ConversionKind
- func (t *PromiseType) Equals(other Type) bool
- func (t *PromiseType) Pretty() pretty.Formatter
- func (t *PromiseType) String() string
- func (*PromiseType) SyntaxNode() hclsyntax.Node
- func (t *PromiseType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type RelativeTraversalExpression
- func (x *RelativeTraversalExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *RelativeTraversalExpression) Format(f fmt.State, c rune)
- func (x *RelativeTraversalExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *RelativeTraversalExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *RelativeTraversalExpression) HasLeadingTrivia() bool
- func (x *RelativeTraversalExpression) HasTrailingTrivia() bool
- func (x *RelativeTraversalExpression) NodeTokens() syntax.NodeTokens
- func (x *RelativeTraversalExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *RelativeTraversalExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *RelativeTraversalExpression) SyntaxNode() hclsyntax.Node
- func (x *RelativeTraversalExpression) Type() Type
- func (x *RelativeTraversalExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type Scope
- func (s *Scope) BindFunctionReference(name string) (*Function, bool)
- func (s *Scope) BindReference(name string) (Definition, bool)
- func (s *Scope) Define(name string, def Definition) bool
- func (s *Scope) DefineFunction(name string, def *Function) bool
- func (s *Scope) DefineScope(name string, syntax hclsyntax.Node) (*Scope, bool)
- func (s *Scope) Pop() *Scope
- func (s *Scope) Push(syntax hclsyntax.Node) *Scope
- func (s *Scope) SyntaxNode() hclsyntax.Node
- func (s *Scope) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type ScopeTraversalExpression
- func (x *ScopeTraversalExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *ScopeTraversalExpression) Format(f fmt.State, c rune)
- func (x *ScopeTraversalExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *ScopeTraversalExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *ScopeTraversalExpression) HasLeadingTrivia() bool
- func (x *ScopeTraversalExpression) HasTrailingTrivia() bool
- func (x *ScopeTraversalExpression) NodeTokens() syntax.NodeTokens
- func (x *ScopeTraversalExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *ScopeTraversalExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *ScopeTraversalExpression) SyntaxNode() hclsyntax.Node
- func (x *ScopeTraversalExpression) Type() Type
- func (x *ScopeTraversalExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type Scopes
- type SetType
- func (t *SetType) AssignableFrom(src Type) bool
- func (t *SetType) ConversionFrom(src Type) ConversionKind
- func (t *SetType) Equals(other Type) bool
- func (t *SetType) Pretty() pretty.Formatter
- func (t *SetType) String() string
- func (*SetType) SyntaxNode() hclsyntax.Node
- func (t *SetType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type SplatExpression
- func (x *SplatExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *SplatExpression) Format(f fmt.State, c rune)
- func (x *SplatExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *SplatExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *SplatExpression) HasLeadingTrivia() bool
- func (x *SplatExpression) HasTrailingTrivia() bool
- func (x *SplatExpression) NodeTokens() syntax.NodeTokens
- func (x *SplatExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *SplatExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *SplatExpression) SyntaxNode() hclsyntax.Node
- func (x *SplatExpression) Type() Type
- func (x *SplatExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type SplatVariable
- type StaticFunctionSignature
- type TemplateExpression
- func (x *TemplateExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *TemplateExpression) Format(f fmt.State, c rune)
- func (x *TemplateExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *TemplateExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *TemplateExpression) HasLeadingTrivia() bool
- func (x *TemplateExpression) HasTrailingTrivia() bool
- func (x *TemplateExpression) NodeTokens() syntax.NodeTokens
- func (x *TemplateExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *TemplateExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *TemplateExpression) SyntaxNode() hclsyntax.Node
- func (x *TemplateExpression) Type() Type
- func (x *TemplateExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type TemplateJoinExpression
- func (x *TemplateJoinExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *TemplateJoinExpression) Format(f fmt.State, c rune)
- func (x *TemplateJoinExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *TemplateJoinExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *TemplateJoinExpression) HasLeadingTrivia() bool
- func (x *TemplateJoinExpression) HasTrailingTrivia() bool
- func (x *TemplateJoinExpression) NodeTokens() syntax.NodeTokens
- func (x *TemplateJoinExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *TemplateJoinExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *TemplateJoinExpression) SyntaxNode() hclsyntax.Node
- func (x *TemplateJoinExpression) Type() Type
- func (x *TemplateJoinExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type Traversable
- type TupleConsExpression
- func (x *TupleConsExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *TupleConsExpression) Format(f fmt.State, c rune)
- func (x *TupleConsExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *TupleConsExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *TupleConsExpression) HasLeadingTrivia() bool
- func (x *TupleConsExpression) HasTrailingTrivia() bool
- func (x *TupleConsExpression) NodeTokens() syntax.NodeTokens
- func (x *TupleConsExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *TupleConsExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *TupleConsExpression) SyntaxNode() hclsyntax.Node
- func (x *TupleConsExpression) Type() Type
- func (x *TupleConsExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type TupleType
- func (t *TupleType) AssignableFrom(src Type) bool
- func (t *TupleType) ConversionFrom(src Type) ConversionKind
- func (t *TupleType) Equals(other Type) bool
- func (t *TupleType) Pretty() pretty.Formatter
- func (t *TupleType) String() string
- func (*TupleType) SyntaxNode() hclsyntax.Node
- func (t *TupleType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type Type
- func GetTraversableType(t Traversable) Type
- func GetTraverserKey(t hcl.Traverser) (cty.Value, Type)
- func InputType(t Type) Type
- func NewOptionalType(t Type) Type
- func NewTupleType(elementTypes ...Type) Type
- func NewUnionType(types ...Type) Type
- func NewUnionTypeAnnotated(types []Type, annotations ...interface{}) Type
- func ResolveOutputs(t Type) Type
- func ResolvePromises(t Type) Type
- type TypedTraversable
- type UnaryOpExpression
- func (x *UnaryOpExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
- func (x *UnaryOpExpression) Format(f fmt.State, c rune)
- func (x *UnaryOpExpression) GetLeadingTrivia() syntax.TriviaList
- func (x *UnaryOpExpression) GetTrailingTrivia() syntax.TriviaList
- func (x *UnaryOpExpression) HasLeadingTrivia() bool
- func (x *UnaryOpExpression) HasTrailingTrivia() bool
- func (x *UnaryOpExpression) NodeTokens() syntax.NodeTokens
- func (x *UnaryOpExpression) OperandType() Type
- func (x *UnaryOpExpression) SetLeadingTrivia(t syntax.TriviaList)
- func (x *UnaryOpExpression) SetTrailingTrivia(t syntax.TriviaList)
- func (x *UnaryOpExpression) SyntaxNode() hclsyntax.Node
- func (x *UnaryOpExpression) Type() Type
- func (x *UnaryOpExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
- type UnionType
- func (t *UnionType) AssignableFrom(src Type) bool
- func (t *UnionType) ConversionFrom(src Type) ConversionKind
- func (t *UnionType) Equals(other Type) bool
- func (t *UnionType) Pretty() pretty.Formatter
- func (t *UnionType) String() string
- func (*UnionType) SyntaxNode() hclsyntax.Node
- func (t *UnionType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
- type ValueTraversable
- type Variable
Constants ¶
This section is empty.
Variables ¶
var ( // NoneType represents the undefined value. NoneType Type = noneType(0) // BoolType represents the set of boolean values. BoolType = NewOpaqueType("boolean") // IntType represents the set of 32-bit integer values. IntType = NewOpaqueType("int") // NumberType represents the set of arbitrary-precision values. NumberType = NewOpaqueType("number") // StringType represents the set of UTF-8 string values. StringType = NewOpaqueType("string") // DynamicType represents the set of all values. DynamicType = NewOpaqueType("dynamic") )
Functions ¶
func AllowMissingVariables ¶
func AllowMissingVariables(options *bindOptions)
func ContainsEventuals ¶
ContainsEventuals returns true if the input type contains output or promise types.
func ContainsOutputs ¶
ContainsOutputs returns true if the input type contains output types.
func ContainsPromises ¶
ContainsPromises returns true if the input type contains promise types.
func ExprNotConvertible ¶
func ExprNotConvertible(destType Type, expr Expression) *hcl.Diagnostic
func GetCollectionTypes ¶
func GetCollectionTypes(collectionType Type, rng hcl.Range, strict bool) (Type, Type, hcl.Diagnostics)
GetCollectionTypes returns the key and value types of the given type if it is a collection.
func GetObjectTypeAnnotation ¶
func GetObjectTypeAnnotation[T any](t *ObjectType) (T, bool)
GetObjectTypeAnnotation retrieves an annotation of the given type from the object type, if one exists.
func HCLExpression ¶
func HCLExpression(x Expression) hcl.Expression
func IsConstType ¶
func IsOptionalType ¶
IsOptionalType returns true if t is an optional type.
func MakeTraverser ¶
func MakeTraverser(t Type) hcl.TraverseIndex
MakeTraverser returns an hcl.TraverseIndex with a key of the appropriate type.
func SkipRangeTypechecking ¶
func SkipRangeTypechecking(options *bindOptions)
func SourceOrderBody ¶
SourceOrderBody sorts the contents of an HCL2 body in source order.
func SourceOrderLess ¶
func SourceOrderLess(a, b hcl.Range) bool
SourceOrderLess returns true if the first range precedes the second when ordered by source position. Positions are ordered first by filename, then by byte offset.
func UnifyTypes ¶
UnifyTypes chooses the most general type that is convertible from all of the input types.
func VisitExpressions ¶
func VisitExpressions(n BodyItem, pre, post ExpressionVisitor) hcl.Diagnostics
VisitExpressions visits each expression that descends from the given body item.
Types ¶
type AnonymousFunctionExpression ¶
type AnonymousFunctionExpression struct { // The signature for the anonymous function. Signature StaticFunctionSignature // The parameter definitions for the anonymous function. Parameters []*Variable // The body of the anonymous function. Body Expression }
AnonymousFunctionExpression represents a semantically-analyzed anonymous function expression.
These expressions are not the result of semantically analyzing syntax nodes. Instead, they may be synthesized by transforms over the IR for a program (e.g. the Apply transform).
func (*AnonymousFunctionExpression) Evaluate ¶
func (x *AnonymousFunctionExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*AnonymousFunctionExpression) Format ¶
func (x *AnonymousFunctionExpression) Format(f fmt.State, c rune)
func (*AnonymousFunctionExpression) GetLeadingTrivia ¶
func (x *AnonymousFunctionExpression) GetLeadingTrivia() syntax.TriviaList
func (*AnonymousFunctionExpression) GetTrailingTrivia ¶
func (x *AnonymousFunctionExpression) GetTrailingTrivia() syntax.TriviaList
func (*AnonymousFunctionExpression) HasLeadingTrivia ¶
func (x *AnonymousFunctionExpression) HasLeadingTrivia() bool
func (*AnonymousFunctionExpression) HasTrailingTrivia ¶
func (x *AnonymousFunctionExpression) HasTrailingTrivia() bool
func (*AnonymousFunctionExpression) NodeTokens ¶
func (x *AnonymousFunctionExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the body of the anonymous function.
func (*AnonymousFunctionExpression) SetLeadingTrivia ¶
func (x *AnonymousFunctionExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*AnonymousFunctionExpression) SetTrailingTrivia ¶
func (x *AnonymousFunctionExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*AnonymousFunctionExpression) SyntaxNode ¶
func (x *AnonymousFunctionExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the body of the anonymous function.
func (*AnonymousFunctionExpression) Type ¶
func (x *AnonymousFunctionExpression) Type() Type
Type returns the type of the anonymous function expression.
TODO: currently this returns the any type. Instead, it should return a function type.
func (*AnonymousFunctionExpression) Typecheck ¶
func (x *AnonymousFunctionExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type Attribute ¶
type Attribute struct { // The syntax node for the attribute, if any. Syntax *hclsyntax.Attribute // The tokens for the attribute. Tokens *syntax.AttributeTokens // The attribute's name. Name string // The attribute's value. Value Expression }
Attribute represents an HCL2 attribute.
func BindAttribute ¶
func BindAttribute(attribute *hclsyntax.Attribute, scope *Scope, tokens syntax.TokenMap, opts ...BindOption, ) (*Attribute, hcl.Diagnostics)
BindAttribute binds an HCL2 attribute using the given scope and token map.
func (*Attribute) GetLeadingTrivia ¶
func (a *Attribute) GetLeadingTrivia() syntax.TriviaList
func (*Attribute) GetTrailingTrivia ¶
func (a *Attribute) GetTrailingTrivia() syntax.TriviaList
func (*Attribute) HasLeadingTrivia ¶
func (*Attribute) HasTrailingTrivia ¶
func (*Attribute) SyntaxNode ¶
SyntaxNode returns the syntax node of the attribute, and will either return an *hclsyntax.Attribute or syntax.None.
type BinaryOpExpression ¶
type BinaryOpExpression struct { // The syntax node associated with the binary operation. Syntax *hclsyntax.BinaryOpExpr // The tokens associated with the expression, if any. Tokens *syntax.BinaryOpTokens // The left-hand operand of the operation. LeftOperand Expression // The operation. Operation *hclsyntax.Operation // The right-hand operand of the operation. RightOperand Expression // contains filtered or unexported fields }
BinaryOpExpression represents a semantically-analyzed binary operation.
func (*BinaryOpExpression) Evaluate ¶
func (x *BinaryOpExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*BinaryOpExpression) GetLeadingTrivia ¶
func (x *BinaryOpExpression) GetLeadingTrivia() syntax.TriviaList
func (*BinaryOpExpression) GetTrailingTrivia ¶
func (x *BinaryOpExpression) GetTrailingTrivia() syntax.TriviaList
func (*BinaryOpExpression) HasLeadingTrivia ¶
func (x *BinaryOpExpression) HasLeadingTrivia() bool
func (*BinaryOpExpression) HasTrailingTrivia ¶
func (x *BinaryOpExpression) HasTrailingTrivia() bool
func (*BinaryOpExpression) LeftOperandType ¶
func (x *BinaryOpExpression) LeftOperandType() Type
LeftOperandType returns the desired type for the left operand of the binary operation.
func (*BinaryOpExpression) NodeTokens ¶
func (x *BinaryOpExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the binary operation.
func (*BinaryOpExpression) RightOperandType ¶
func (x *BinaryOpExpression) RightOperandType() Type
RightOperandType returns the desired type for the right operand of the binary operation.
func (*BinaryOpExpression) SetLeadingTrivia ¶
func (x *BinaryOpExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*BinaryOpExpression) SetTrailingTrivia ¶
func (x *BinaryOpExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*BinaryOpExpression) SyntaxNode ¶
func (x *BinaryOpExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the binary operation.
func (*BinaryOpExpression) Type ¶
func (x *BinaryOpExpression) Type() Type
Type returns the type of the binary operation.
func (*BinaryOpExpression) Typecheck ¶
func (x *BinaryOpExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type BindOption ¶
type BindOption func(options *bindOptions)
type Block ¶
type Block struct { // The syntax node for the block, if any. Syntax *hclsyntax.Block // The tokens for the block. Tokens *syntax.BlockTokens // The block's type. Type string // The block's labels. Labels []string // The block's body. Body *Body }
Block represents an HCL2 block.
func BindBlock ¶
func BindBlock(block *hclsyntax.Block, scopes Scopes, tokens syntax.TokenMap, opts ...BindOption, ) (*Block, hcl.Diagnostics)
BindBlock binds an HCL2 block using the given scopes and token map.
func (*Block) GetLeadingTrivia ¶
func (b *Block) GetLeadingTrivia() syntax.TriviaList
func (*Block) GetTrailingTrivia ¶
func (b *Block) GetTrailingTrivia() syntax.TriviaList
func (*Block) HasLeadingTrivia ¶
func (*Block) HasTrailingTrivia ¶
func (*Block) SyntaxNode ¶
SyntaxNode returns the syntax node of the block, and will either return an *hclsyntax.Block or syntax.None.
type Body ¶
type Body struct { // The syntax node for the body, if any. Syntax *hclsyntax.Body // The tokens for the body. Tokens *syntax.BodyTokens // The items that make up the body's contents. Items []BodyItem }
Body represents an HCL2 body. A Body may be the root of an HCL2 file or the contents of an HCL2 block.
func BindBody ¶
func BindBody(body *hclsyntax.Body, scopes Scopes, tokens syntax.TokenMap, opts ...BindOption, ) (*Body, hcl.Diagnostics)
BindBody binds an HCL2 body using the given scopes and token map.
func (*Body) GetLeadingTrivia ¶
func (b *Body) GetLeadingTrivia() syntax.TriviaList
func (*Body) GetTrailingTrivia ¶
func (b *Body) GetTrailingTrivia() syntax.TriviaList
func (*Body) HasLeadingTrivia ¶
func (*Body) HasTrailingTrivia ¶
func (*Body) SyntaxNode ¶
SyntaxNode returns the syntax node of the body, and will either return an *hclsyntax.Body or syntax.None.
type BodyItem ¶
type BodyItem interface { // SyntaxNode returns syntax node of the item. SyntaxNode() hclsyntax.Node // contains filtered or unexported methods }
BodyItem represents either an *Attribute or a *Block that is part of an HCL2 Body.
func BodyItemIdentityVisitor ¶
func VisitBodyItem ¶
func VisitBodyItem(n BodyItem, pre, post BodyItemVisitor) (BodyItem, hcl.Diagnostics)
type BodyItemVisitor ¶
A BodyItemVisitor is a function that visits and optionally replaces the contents of a body item.
type ConditionalExpression ¶
type ConditionalExpression struct { // The syntax node associated with the conditional expression. Syntax *hclsyntax.ConditionalExpr // The tokens associated with the expression, if any. Tokens syntax.NodeTokens // The condition. Condition Expression // The result of the expression if the condition evaluates to true. TrueResult Expression // The result of the expression if the condition evaluates to false. FalseResult Expression // contains filtered or unexported fields }
ConditionalExpression represents a semantically-analzed conditional expression (i.e. <condition> '?' <true> ':' <false>).
func (*ConditionalExpression) Evaluate ¶
func (x *ConditionalExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*ConditionalExpression) GetLeadingTrivia ¶
func (x *ConditionalExpression) GetLeadingTrivia() syntax.TriviaList
func (*ConditionalExpression) GetTrailingTrivia ¶
func (x *ConditionalExpression) GetTrailingTrivia() syntax.TriviaList
func (*ConditionalExpression) HasLeadingTrivia ¶
func (x *ConditionalExpression) HasLeadingTrivia() bool
func (*ConditionalExpression) HasTrailingTrivia ¶
func (x *ConditionalExpression) HasTrailingTrivia() bool
func (*ConditionalExpression) NodeTokens ¶
func (x *ConditionalExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the conditional expression.
func (*ConditionalExpression) SetLeadingTrivia ¶
func (x *ConditionalExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*ConditionalExpression) SetTrailingTrivia ¶
func (x *ConditionalExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*ConditionalExpression) SyntaxNode ¶
func (x *ConditionalExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the conditional expression.
func (*ConditionalExpression) Type ¶
func (x *ConditionalExpression) Type() Type
Type returns the type of the conditional expression.
func (*ConditionalExpression) Typecheck ¶
func (x *ConditionalExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type ConstType ¶
type ConstType struct { // Type is the underlying value type. Type Type // Value is the constant value. Value cty.Value }
ConstType represents a type that is a single constant value.
func NewConstType ¶
NewConstType creates a new constant type with the given type and value.
func (*ConstType) AssignableFrom ¶
AssignableFrom returns true if this type is assignable from the indicated source type. A const(value) is assignable from const(value).
func (*ConstType) ConversionFrom ¶
func (t *ConstType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type. The const type is only convertible from itself.
func (*ConstType) Equals ¶
Equals returns true if this type has the same identity as the given type.
func (*ConstType) SyntaxNode ¶
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*ConstType) Traverse ¶
func (t *ConstType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the type with the given traverser. The result is the traversal result of the underlying type.
type Constant ¶
type Constant struct { // The syntax node associated with the constant definition, if any. Syntax hclsyntax.Node // The name of the constant. Name string // The value of the constant. ConstantValue cty.Value // contains filtered or unexported fields }
A Constant is a traversable, typed definition that represents a named constant.
func (*Constant) SyntaxNode ¶
SyntaxNode returns the constant's syntax node or syntax.None.
func (*Constant) Traverse ¶
func (c *Constant) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the constant's value.
type ConversionKind ¶
type ConversionKind int
const ( NoConversion ConversionKind = 0 UnsafeConversion ConversionKind = 1 SafeConversion ConversionKind = 2 )
func (ConversionKind) Exists ¶
func (k ConversionKind) Exists() bool
type Definition ¶
type Definition interface { Traversable SyntaxNode() hclsyntax.Node }
Definition represents a single definition in a Scope.
type EnumType ¶
type EnumType struct { // Elements are the possible values of the enum. Elements []cty.Value // The type of the enum's values. Type Type // Token that uniquely identifies a EnumType. // Given EnumA, EnumB of type EnumType // EnumA.Token != EnumB.Token => EnumA != EnumB (regardless of other fields) // // It is the responsibility of enum constructors to ensure that given EnumA, // EnumB of type EnumType // // EnumA.Token = EnumB.Token => EnumA = EnumB (all fields match) // // Failure to do so may lead to panics. Token string // Annotations records any annotations associated with the object type. Annotations []interface{} // contains filtered or unexported fields }
EnumType represents values of a single type, and a closed set of possible values.
func NewEnumType ¶
func (*EnumType) AssignableFrom ¶
AssignableFrom returns true if this type is assignable from the indicated source type. The whole point of enums is they are a unique type, so we can't convert between them.
func (*EnumType) ConversionFrom ¶
func (t *EnumType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type. Most languages support casting between value types and an enum of that value. When the value is constant, we can determine if the cast is valid. Otherwise it is valid but unsafe.
func (*EnumType) SyntaxNode ¶
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*EnumType) Traverse ¶
func (t *EnumType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the enum type with the given traverser. This always fails.
type ErrorExpression ¶
type ErrorExpression struct { // The syntax node associated with the error, if any. Syntax hclsyntax.Node // The tokens associated with the error. Tokens syntax.NodeTokens // The message associated with the error. Message string // contains filtered or unexported fields }
ErrorExpression represents an expression that could not be bound due to an error.
func (*ErrorExpression) Evaluate ¶
func (x *ErrorExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*ErrorExpression) GetLeadingTrivia ¶
func (x *ErrorExpression) GetLeadingTrivia() syntax.TriviaList
func (*ErrorExpression) GetTrailingTrivia ¶
func (x *ErrorExpression) GetTrailingTrivia() syntax.TriviaList
func (*ErrorExpression) HasLeadingTrivia ¶
func (x *ErrorExpression) HasLeadingTrivia() bool
func (*ErrorExpression) HasTrailingTrivia ¶
func (x *ErrorExpression) HasTrailingTrivia() bool
func (*ErrorExpression) NodeTokens ¶
func (x *ErrorExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the error expression.
func (*ErrorExpression) SetLeadingTrivia ¶
func (x *ErrorExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*ErrorExpression) SetTrailingTrivia ¶
func (x *ErrorExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*ErrorExpression) SyntaxNode ¶
func (x *ErrorExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the error expression.
func (*ErrorExpression) Type ¶
func (x *ErrorExpression) Type() Type
Type returns the type of the error expression.
func (*ErrorExpression) Typecheck ¶
func (x *ErrorExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type Expression ¶
type Expression interface { // SyntaxNode returns the hclsyntax.Node associated with the expression. SyntaxNode() hclsyntax.Node // NodeTokens returns the syntax.Tokens associated with the expression. NodeTokens() syntax.NodeTokens // SetLeadingTrivia sets the leading trivia associated with the expression. SetLeadingTrivia(syntax.TriviaList) // SetTrailingTrivia sets the trailing trivia associated with the expression. SetTrailingTrivia(syntax.TriviaList) // Type returns the type of the expression. Type() Type // Typecheck recomputes the type of the expression, optionally typechecking its operands first. Typecheck(typecheckOperands bool) hcl.Diagnostics // Evaluate evaluates the expression. Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics) // contains filtered or unexported methods }
Expression represents a semantically-analyzed HCL2 expression.
func BindExpression ¶
func BindExpression(syntax hclsyntax.Node, scope *Scope, tokens _syntax.TokenMap, opts ...BindOption, ) (Expression, hcl.Diagnostics)
BindExpression binds an HCL2 expression using the given scope and token map.
func BindExpressionText ¶
func BindExpressionText(source string, scope *Scope, initialPos hcl.Pos, opts ...BindOption, ) (Expression, hcl.Diagnostics)
BindExpressionText parses and binds an HCL2 expression using the given scope.
func IdentityVisitor ¶
func IdentityVisitor(n Expression) (Expression, hcl.Diagnostics)
IdentityVisitor is a ExpressionVisitor that returns the input node unchanged.
func VisitExpression ¶
func VisitExpression(n Expression, pre, post ExpressionVisitor) (Expression, hcl.Diagnostics)
VisitExpression visits each node in an expression tree using the given pre- and post-order visitors. If the preorder visitor returns a new node, that node's descendents will be visited. VisitExpression returns the result of the post-order visitor. All diagnostics are accumulated.
type ExpressionVisitor ¶
type ExpressionVisitor func(n Expression) (Expression, hcl.Diagnostics)
An ExpressionVisitor is a function that visits and optionally replaces a node in an expression tree.
type ForExpression ¶
type ForExpression struct { fmt.Formatter // The syntax node associated with the for expression. Syntax *hclsyntax.ForExpr // The tokens associated with the expression, if any. Tokens syntax.NodeTokens // The key variable, if any. KeyVariable *Variable // The value variable. ValueVariable *Variable // The collection being iterated. Collection Expression // The expression that generates the keys of the result, if any. If this field is non-nil, the result is a map. Key Expression // The expression that generates the values of the result. Value Expression // The condition that filters the items of the result, if any. Condition Expression // True if the value expression is being grouped. Group bool // Whether the collection type should be strictly type-checked // When true, unsupported collection types will result in an error // otherwise a warning will be emitted StrictCollectionTypechecking bool // contains filtered or unexported fields }
ForExpression represents a semantically-analyzed for expression.
func (*ForExpression) Evaluate ¶
func (x *ForExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*ForExpression) GetLeadingTrivia ¶
func (x *ForExpression) GetLeadingTrivia() syntax.TriviaList
func (*ForExpression) GetTrailingTrivia ¶
func (x *ForExpression) GetTrailingTrivia() syntax.TriviaList
func (*ForExpression) HasLeadingTrivia ¶
func (x *ForExpression) HasLeadingTrivia() bool
func (*ForExpression) HasTrailingTrivia ¶
func (x *ForExpression) HasTrailingTrivia() bool
func (*ForExpression) NodeTokens ¶
func (x *ForExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the for expression.
func (*ForExpression) SetLeadingTrivia ¶
func (x *ForExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*ForExpression) SetTrailingTrivia ¶
func (x *ForExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*ForExpression) SyntaxNode ¶
func (x *ForExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the for expression.
func (*ForExpression) Type ¶
func (x *ForExpression) Type() Type
Type returns the type of the for expression.
func (*ForExpression) Typecheck ¶
func (x *ForExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function represents a function definition.
func NewFunction ¶
func NewFunction(signature FunctionSignature) *Function
NewFunction creates a new function with the given signature.
func (*Function) GetSignature ¶
func (f *Function) GetSignature(arguments []Expression) (StaticFunctionSignature, hcl.Diagnostics)
GetSignature returns the static signature of the function when it is invoked with the given arguments.
func (*Function) SyntaxNode ¶
SyntaxNode returns the syntax node for the function, which is always syntax.None.
func (*Function) Traverse ¶
func (f *Function) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the function definition. This will always fail: functions are not traversable.
type FunctionCallExpression ¶
type FunctionCallExpression struct { // The syntax node associated with the function call expression. Syntax *hclsyntax.FunctionCallExpr // The tokens associated with the expression, if any. Tokens *syntax.FunctionCallTokens // The name of the called function. Name string // The signature of the called function. Signature StaticFunctionSignature // The arguments to the function call. Args []Expression // ExpandFinal indicates that the final argument should be a tuple, list, or set whose elements will be passed as // individual arguments to the function. ExpandFinal bool }
FunctionCallExpression represents a semantically-analyzed function call expression.
func (*FunctionCallExpression) Evaluate ¶
func (x *FunctionCallExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*FunctionCallExpression) Format ¶
func (x *FunctionCallExpression) Format(f fmt.State, c rune)
func (*FunctionCallExpression) GetLeadingTrivia ¶
func (x *FunctionCallExpression) GetLeadingTrivia() syntax.TriviaList
func (*FunctionCallExpression) GetTrailingTrivia ¶
func (x *FunctionCallExpression) GetTrailingTrivia() syntax.TriviaList
func (*FunctionCallExpression) HasLeadingTrivia ¶
func (x *FunctionCallExpression) HasLeadingTrivia() bool
func (*FunctionCallExpression) HasTrailingTrivia ¶
func (x *FunctionCallExpression) HasTrailingTrivia() bool
func (*FunctionCallExpression) NodeTokens ¶
func (x *FunctionCallExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the function call expression.
func (*FunctionCallExpression) SetLeadingTrivia ¶
func (x *FunctionCallExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*FunctionCallExpression) SetTrailingTrivia ¶
func (x *FunctionCallExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*FunctionCallExpression) SyntaxNode ¶
func (x *FunctionCallExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the function call expression.
func (*FunctionCallExpression) Type ¶
func (x *FunctionCallExpression) Type() Type
Type returns the type of the function call expression.
func (*FunctionCallExpression) Typecheck ¶
func (x *FunctionCallExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type FunctionSignature ¶
type FunctionSignature interface { // GetSignature returns the static signature for the function when invoked with the given arguments. GetSignature(arguments []Expression) (StaticFunctionSignature, hcl.Diagnostics) }
FunctionSignature represents a possibly-type-polymorphic function signature.
type GenericFunctionSignature ¶
type GenericFunctionSignature func(arguments []Expression) (StaticFunctionSignature, hcl.Diagnostics)
GenericFunctionSignature represents a type-polymorphic function signature. The underlying function will be invoked by GenericFunctionSignature.GetSignature to compute the static signature of the function.
func (GenericFunctionSignature) GetSignature ¶
func (fs GenericFunctionSignature) GetSignature(arguments []Expression) (StaticFunctionSignature, hcl.Diagnostics)
GetSignature returns the static function signature when it is invoked with the given arguments.
type IndexExpression ¶
type IndexExpression struct { // The syntax node associated with the index expression. Syntax *hclsyntax.IndexExpr // The tokens associated with the expression, if any. Tokens *syntax.IndexTokens // The collection being indexed. Collection Expression // The index key. Key Expression // Whether the collection type should be strictly type-checked // When true, unsupported collection types will result in an error // otherwise a warning will be emitted StrictCollectionTypechecking bool // contains filtered or unexported fields }
IndexExpression represents a semantically-analyzed index expression.
func (*IndexExpression) Evaluate ¶
func (x *IndexExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*IndexExpression) GetLeadingTrivia ¶
func (x *IndexExpression) GetLeadingTrivia() syntax.TriviaList
func (*IndexExpression) GetTrailingTrivia ¶
func (x *IndexExpression) GetTrailingTrivia() syntax.TriviaList
func (*IndexExpression) HasLeadingTrivia ¶
func (x *IndexExpression) HasLeadingTrivia() bool
func (*IndexExpression) HasTrailingTrivia ¶
func (x *IndexExpression) HasTrailingTrivia() bool
func (*IndexExpression) KeyType ¶
func (x *IndexExpression) KeyType() Type
KeyType returns the expected type of the index expression's key.
func (*IndexExpression) NodeTokens ¶
func (x *IndexExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the index expression.
func (*IndexExpression) SetLeadingTrivia ¶
func (x *IndexExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*IndexExpression) SetTrailingTrivia ¶
func (x *IndexExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*IndexExpression) SyntaxNode ¶
func (x *IndexExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the index expression.
func (*IndexExpression) Type ¶
func (x *IndexExpression) Type() Type
Type returns the type of the index expression.
func (*IndexExpression) Typecheck ¶
func (x *IndexExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type Keyword ¶
type Keyword string
A Keyword is a non-traversable definition that allows scope traversals to bind to arbitrary keywords.
func (Keyword) SyntaxNode ¶
SyntaxNode returns the syntax node for the keyword, which is always syntax.None.
func (Keyword) Traverse ¶
func (kw Keyword) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the keyword, and always fails.
type ListType ¶
type ListType struct { // ElementType is the element type of the list. ElementType Type }
ListType represents lists of particular element types.
func NewListType ¶
NewListType creates a new list type with the given element type.
func (*ListType) AssignableFrom ¶
AssignableFrom returns true if this type is assignable from the indicated source type. A list(T) is assignable from values of type list(U) where T is assignable from U.
func (*ListType) ConversionFrom ¶
func (t *ListType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type. A list(T) is safely convertible from list(U), set(U), or tuple(U_0 ... U_N) if the element type(s) U is/are safely convertible to T. If any element type is unsafely convertible to T and no element type is safely convertible to T, the conversion is unsafe. Otherwise, no conversion exists.
func (*ListType) SyntaxNode ¶
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*ListType) Traverse ¶
func (t *ListType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the optional type with the given traverser. The result type of traverse(list(T)) is T; the traversal fails if the traverser is not a number.
type LiteralValueExpression ¶
type LiteralValueExpression struct { // The syntax node associated with the literal value expression. Syntax *hclsyntax.LiteralValueExpr // The tokens associated with the expression, if any. Tokens *syntax.LiteralValueTokens // The value of the expression. Value cty.Value // contains filtered or unexported fields }
LiteralValueExpression represents a semantically-analyzed literal value expression.
func (*LiteralValueExpression) Evaluate ¶
func (x *LiteralValueExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*LiteralValueExpression) Format ¶
func (x *LiteralValueExpression) Format(f fmt.State, c rune)
func (*LiteralValueExpression) GetLeadingTrivia ¶
func (x *LiteralValueExpression) GetLeadingTrivia() syntax.TriviaList
func (*LiteralValueExpression) GetTrailingTrivia ¶
func (x *LiteralValueExpression) GetTrailingTrivia() syntax.TriviaList
func (*LiteralValueExpression) HasLeadingTrivia ¶
func (x *LiteralValueExpression) HasLeadingTrivia() bool
func (*LiteralValueExpression) HasTrailingTrivia ¶
func (x *LiteralValueExpression) HasTrailingTrivia() bool
func (*LiteralValueExpression) NodeTokens ¶
func (x *LiteralValueExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the literal value expression.
func (*LiteralValueExpression) SetLeadingTrivia ¶
func (x *LiteralValueExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*LiteralValueExpression) SetTrailingTrivia ¶
func (x *LiteralValueExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*LiteralValueExpression) SyntaxNode ¶
func (x *LiteralValueExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the literal value expression.
func (*LiteralValueExpression) Type ¶
func (x *LiteralValueExpression) Type() Type
Type returns the type of the literal value expression.
func (*LiteralValueExpression) Typecheck ¶
func (x *LiteralValueExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type MapType ¶
type MapType struct { // ElementType is the element type of the map. ElementType Type }
MapType represents maps from strings to particular element types.
func NewMapType ¶
NewMapType creates a new map type with the given element type.
func (*MapType) AssignableFrom ¶
AssignableFrom returns true if this type is assignable from the indicated source type. A map(T) is assignable from values of type map(U) where T is assignable from U or object(K_0=U_0, ..., K_N=U_N) if T is assignable from the unified type of U_0 through U_N.
func (*MapType) ConversionFrom ¶
func (t *MapType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type. A map(T) is safely convertible from map(U) or object({K_0 = U_0 ... K_N = U_N}) if the element type(s) U is/are safely convertible to T. If any element type is unsafely convertible to T and no element type is safely convertible to T, the conversion is unsafe. Otherwise, no conversion exists.
func (*MapType) SyntaxNode ¶
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*MapType) Traverse ¶
func (t *MapType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the optional type with the given traverser. The result type of traverse(map(T)) is T; the traversal fails if the traverser is not a string.
type ObjectConsExpression ¶
type ObjectConsExpression struct { // The syntax node associated with the object construction expression. Syntax *hclsyntax.ObjectConsExpr // The tokens associated with the expression, if any. Tokens *syntax.ObjectConsTokens // The items that comprise the object construction expression. Items []ObjectConsItem // contains filtered or unexported fields }
ObjectConsExpression represents a semantically-analyzed object construction expression.
func (*ObjectConsExpression) Evaluate ¶
func (x *ObjectConsExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*ObjectConsExpression) GetLeadingTrivia ¶
func (x *ObjectConsExpression) GetLeadingTrivia() syntax.TriviaList
func (*ObjectConsExpression) GetTrailingTrivia ¶
func (x *ObjectConsExpression) GetTrailingTrivia() syntax.TriviaList
func (*ObjectConsExpression) HasLeadingTrivia ¶
func (x *ObjectConsExpression) HasLeadingTrivia() bool
func (*ObjectConsExpression) HasTrailingTrivia ¶
func (x *ObjectConsExpression) HasTrailingTrivia() bool
func (*ObjectConsExpression) NodeTokens ¶
func (x *ObjectConsExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the object construction expression.
func (*ObjectConsExpression) SetLeadingTrivia ¶
func (x *ObjectConsExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*ObjectConsExpression) SetTrailingTrivia ¶
func (x *ObjectConsExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*ObjectConsExpression) SyntaxNode ¶
func (x *ObjectConsExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the object construction expression.
func (*ObjectConsExpression) Type ¶
func (x *ObjectConsExpression) Type() Type
Type returns the type of the object construction expression.
func (*ObjectConsExpression) Typecheck ¶
func (x *ObjectConsExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
func (*ObjectConsExpression) WithType ¶
func (x *ObjectConsExpression) WithType(updateType func(Type) *ObjectConsExpression) *ObjectConsExpression
type ObjectConsItem ¶
type ObjectConsItem struct { // The key. Key Expression // The value. Value Expression }
ObjectConsItem records a key-value pair that is part of object construction expression.
type ObjectType ¶
type ObjectType struct { // Properties records the types of the object's properties. Properties map[string]Type // Annotations records any annotations associated with the object type. Annotations []interface{} // contains filtered or unexported fields }
ObjectType represents schematized maps from strings to particular types.
func NewObjectType ¶
func NewObjectType(properties map[string]Type, annotations ...interface{}) *ObjectType
NewObjectType creates a new object type with the given properties and annotations.
func (*ObjectType) Annotate ¶
func (t *ObjectType) Annotate(annotations ...interface{})
Annotate adds annotations to the object type. Annotations may be retrieved by GetObjectTypeAnnotation.
func (*ObjectType) AssignableFrom ¶
func (t *ObjectType) AssignableFrom(src Type) bool
AssignableFrom returns true if this type is assignable from the indicated source type. An object({K_0 = T_0, ..., K_N = T_N}) is assignable from U = object({K_0 = U_0, ... K_M = U_M}), where T_I is assignable from U[K_I] for all I from 0 to N.
func (*ObjectType) ConversionFrom ¶
func (t *ObjectType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type.
An object({K_0 = T_0, ..., K_N = T_N}) is convertible from object({K_0 = U_0, ... K_M = U_M}) if all properties that exist in both types are convertible, and any keys that do not exist in the source type are optional in the destination type. If any of these conversions are unsafe, the whole conversion is unsafe; otherwise, the conversion is safe.
An object({K_0 = T_0, ..., K_N = T_N}) is convertible from a map(U) if U is convertible to all of T_0 through T_N. This conversion is always unsafe, and may fail if the map does not contain an appropriate set of keys for the destination type.
func (*ObjectType) Equals ¶
func (t *ObjectType) Equals(other Type) bool
Equals returns true if this type has the same identity as the given type.
func (*ObjectType) Pretty ¶
func (t *ObjectType) Pretty() pretty.Formatter
func (*ObjectType) String ¶
func (t *ObjectType) String() string
func (*ObjectType) SyntaxNode ¶
func (*ObjectType) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*ObjectType) Traverse ¶
func (t *ObjectType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the optional type with the given traverser. The result type of traverse(object({K_0 = T_0, ..., K_N = T_N})) is T_i if the traverser is the string literal K_i. If the traverser is a string but not a literal, the result type is any.
type OpaqueType ¶
type OpaqueType string
OpaqueType represents a type that is named by a string.
func NewOpaqueType ¶
func NewOpaqueType(name string) *OpaqueType
func (*OpaqueType) AssignableFrom ¶
func (t *OpaqueType) AssignableFrom(src Type) bool
AssignableFrom returns true if this type is assignable from the indicated source type. A token(name) is assignable from token(name).
func (*OpaqueType) ConversionFrom ¶
func (t *OpaqueType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type.
In general, an opaque type is only convertible from itself (in addition to the standard dynamic and union conversions). However, there are special rules for the builtin types:
- The dynamic type is safely convertible from any other type, and is unsafely convertible _to_ any other type - The string type is safely convertible from bool, number, and int - The number type is safely convertible from int and unsafely convertible from string - The int type is unsafely convertible from string - The bool type is unsafely convertible from string
func (*OpaqueType) Equals ¶
func (t *OpaqueType) Equals(other Type) bool
Equals returns true if this type has the same identity as the given type.
func (*OpaqueType) Pretty ¶
func (t *OpaqueType) Pretty() pretty.Formatter
func (*OpaqueType) String ¶
func (t *OpaqueType) String() string
func (*OpaqueType) SyntaxNode ¶
func (*OpaqueType) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*OpaqueType) Traverse ¶
func (t *OpaqueType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the opaque type with the given traverser. The result type of traverse(opaque(name)) is dynamic if name is "dynamic"; otherwise the traversal fails.
type OutputType ¶
type OutputType struct { // ElementType is the element type of the output. ElementType Type }
OutputType represents eventual values that carry additional application-specific information.
func NewOutputType ¶
func NewOutputType(elementType Type) *OutputType
NewOutputType creates a new output type with the given element type after replacing any output or promise types within the element type with their respective element types.
func (*OutputType) AssignableFrom ¶
func (t *OutputType) AssignableFrom(src Type) bool
AssignableFrom returns true if this type is assignable from the indicated source type. An output(T) is assignable from values of type output(U), promise(U), and U, where T is assignable from U.
func (*OutputType) ConversionFrom ¶
func (t *OutputType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type. An output(T) is convertible from a type U, output(U), or promise(U) if U is convertible to T. If the conversion from U to T is unsafe, the entire conversion is unsafe. Otherwise, the conversion is safe.
func (*OutputType) Equals ¶
func (t *OutputType) Equals(other Type) bool
Equals returns true if this type has the same identity as the given type.
func (*OutputType) Pretty ¶
func (t *OutputType) Pretty() pretty.Formatter
func (*OutputType) String ¶
func (t *OutputType) String() string
func (*OutputType) SyntaxNode ¶
func (*OutputType) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*OutputType) Traverse ¶
func (t *OutputType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the output type with the given traverser. The result type of traverse(output(T)) is output(traverse(T)).
type Parameter ¶
type Parameter struct { Name string // The name of the parameter. Type Type // The type of the parameter. }
Parameter represents a single function parameter.
type PromiseType ¶
type PromiseType struct { // ElementType is the element type of the promise. ElementType Type }
PromiseType represents eventual values that do not carry additional information.
func NewPromiseType ¶
func NewPromiseType(elementType Type) *PromiseType
NewPromiseType creates a new promise type with the given element type after replacing any promise types within the element type with their respective element types.
func (*PromiseType) AssignableFrom ¶
func (t *PromiseType) AssignableFrom(src Type) bool
AssignableFrom returns true if this type is assignable from the indicated source type. A promise(T) is assignable from values of type promise(U) and U, where T is assignable from U.
func (*PromiseType) ConversionFrom ¶
func (t *PromiseType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type. An promise(T) is convertible from a type U or promise(U) if U is convertible to T. If the conversion from U to T is unsafe, the entire conversion is unsafe. Otherwise, the conversion is safe.
func (*PromiseType) Equals ¶
func (t *PromiseType) Equals(other Type) bool
Equals returns true if this type has the same identity as the given type.
func (*PromiseType) Pretty ¶
func (t *PromiseType) Pretty() pretty.Formatter
func (*PromiseType) String ¶
func (t *PromiseType) String() string
func (*PromiseType) SyntaxNode ¶
func (*PromiseType) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*PromiseType) Traverse ¶
func (t *PromiseType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the promise type with the given traverser. The result type of traverse(promise(T)) is promise(traverse(T)).
type RelativeTraversalExpression ¶
type RelativeTraversalExpression struct { // The syntax node associated with the relative traversal expression. Syntax *hclsyntax.RelativeTraversalExpr // The tokens associated with the expression, if any. Tokens *syntax.RelativeTraversalTokens // The expression that computes the value being traversed. Source Expression // The traversal's parts. Parts []Traversable // The traversers. Traversal hcl.Traversal }
RelativeTraversalExpression represents a semantically-analyzed relative traversal expression.
func (*RelativeTraversalExpression) Evaluate ¶
func (x *RelativeTraversalExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*RelativeTraversalExpression) Format ¶
func (x *RelativeTraversalExpression) Format(f fmt.State, c rune)
func (*RelativeTraversalExpression) GetLeadingTrivia ¶
func (x *RelativeTraversalExpression) GetLeadingTrivia() syntax.TriviaList
func (*RelativeTraversalExpression) GetTrailingTrivia ¶
func (x *RelativeTraversalExpression) GetTrailingTrivia() syntax.TriviaList
func (*RelativeTraversalExpression) HasLeadingTrivia ¶
func (x *RelativeTraversalExpression) HasLeadingTrivia() bool
func (*RelativeTraversalExpression) HasTrailingTrivia ¶
func (x *RelativeTraversalExpression) HasTrailingTrivia() bool
func (*RelativeTraversalExpression) NodeTokens ¶
func (x *RelativeTraversalExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the relative traversal expression.
func (*RelativeTraversalExpression) SetLeadingTrivia ¶
func (x *RelativeTraversalExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*RelativeTraversalExpression) SetTrailingTrivia ¶
func (x *RelativeTraversalExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*RelativeTraversalExpression) SyntaxNode ¶
func (x *RelativeTraversalExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the relative traversal expression.
func (*RelativeTraversalExpression) Type ¶
func (x *RelativeTraversalExpression) Type() Type
Type returns the type of the relative traversal expression.
func (*RelativeTraversalExpression) Typecheck ¶
func (x *RelativeTraversalExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
A Scope is used to map names to definitions during expression binding.
A scope has three namespaces:
- one that is exclusive to functions
- one that is exclusive to output variables
- and one that contains config variables, local variables and resource definitions.
When binding a reference, we check `defs` and `outputs`. When binding a function, we check `functions`. Definitions within a namespace such as `defs`, `outputs` or `functions` are expected to have a unique identifier and cannot be redeclared.
var TypeScope *Scope
func NewRootScope ¶
NewRootScope returns a new unparented scope associated with the given syntax node.
func (*Scope) BindFunctionReference ¶
BindFunctionReference returns the function definition that corresponds to the given name, if any. Each parent scope is checked until a definition is found or no parent scope remains.
func (*Scope) BindReference ¶
func (s *Scope) BindReference(name string) (Definition, bool)
BindReference returns the definition that corresponds to the given name, if any. Each parent scope is checked until a definition is found or no parent scope remains.
func (*Scope) Define ¶
func (s *Scope) Define(name string, def Definition) bool
Define maps the given name to the given definition. If the name is already defined in this scope, the existing definition is not overwritten and Define returns false.
func (*Scope) DefineFunction ¶
DefineFunction maps the given function name to the given function definition. If the function is alreadu defined in this scope, the definition is not overwritten and DefineFunction returns false.
func (*Scope) DefineScope ¶
DefineScope defines a child scope with the given name. If the name is already defined in this scope, the existing definition is not overwritten and DefineScope returns false.
func (*Scope) SyntaxNode ¶
SyntaxNode returns the syntax node associated with the scope, if any.
func (*Scope) Traverse ¶
func (s *Scope) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the scope using the given traverser. If the traverser is a literal string that refers to a name defined within the scope or one of its ancestors, the traversal returns the corresponding definition.
type ScopeTraversalExpression ¶
type ScopeTraversalExpression struct { // The syntax node associated with the scope traversal expression. Syntax *hclsyntax.ScopeTraversalExpr // The tokens associated with the expression, if any. Tokens *syntax.ScopeTraversalTokens // The traversal's parts. Parts []Traversable // The root name. RootName string // The traversers. Traversal hcl.Traversal }
ScopeTraversalExpression represents a semantically-analyzed scope traversal expression.
func ConstantReference ¶
func ConstantReference(c *Constant) *ScopeTraversalExpression
func VariableReference ¶
func VariableReference(v *Variable) *ScopeTraversalExpression
func (*ScopeTraversalExpression) Evaluate ¶
func (x *ScopeTraversalExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*ScopeTraversalExpression) Format ¶
func (x *ScopeTraversalExpression) Format(f fmt.State, c rune)
func (*ScopeTraversalExpression) GetLeadingTrivia ¶
func (x *ScopeTraversalExpression) GetLeadingTrivia() syntax.TriviaList
func (*ScopeTraversalExpression) GetTrailingTrivia ¶
func (x *ScopeTraversalExpression) GetTrailingTrivia() syntax.TriviaList
func (*ScopeTraversalExpression) HasLeadingTrivia ¶
func (x *ScopeTraversalExpression) HasLeadingTrivia() bool
func (*ScopeTraversalExpression) HasTrailingTrivia ¶
func (x *ScopeTraversalExpression) HasTrailingTrivia() bool
func (*ScopeTraversalExpression) NodeTokens ¶
func (x *ScopeTraversalExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the scope traversal expression.
func (*ScopeTraversalExpression) SetLeadingTrivia ¶
func (x *ScopeTraversalExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*ScopeTraversalExpression) SetTrailingTrivia ¶
func (x *ScopeTraversalExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*ScopeTraversalExpression) SyntaxNode ¶
func (x *ScopeTraversalExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the scope traversal expression.
func (*ScopeTraversalExpression) Type ¶
func (x *ScopeTraversalExpression) Type() Type
Type returns the type of the scope traversal expression.
func (*ScopeTraversalExpression) Typecheck ¶
func (x *ScopeTraversalExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type Scopes ¶
type Scopes interface { // GetScopesForBlock returns the Scopes that should be used when binding the given block. GetScopesForBlock(block *hclsyntax.Block) (Scopes, hcl.Diagnostics) // GetScopeForAttribute returns the *Scope that should be used when binding the given attribute. GetScopeForAttribute(attribute *hclsyntax.Attribute) (*Scope, hcl.Diagnostics) }
Scopes is the interface that is used fetch the scope that should be used when binding a block or attribute.
func StaticScope ¶
StaticScope returns a Scopes that uses the given *Scope for all blocks and attributes.
type SetType ¶
type SetType struct { // ElementType is the element type of the set. ElementType Type }
SetType represents sets of particular element types.
func NewSetType ¶
NewSetType creates a new set type with the given element type.
func (*SetType) AssignableFrom ¶
AssignableFrom returns true if this type is assignable from the indicated source type. A set(T) is assignable from values of type set(U) where T is assignable from U.
func (*SetType) ConversionFrom ¶
func (t *SetType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type. A set(T) is convertible from a set(U) if a conversion exists from U to T. If the conversion from U to T is unsafe, the entire conversion is unsafe; otherwise the conversion is safe. An unsafe conversion exists from list(U) or or tuple(U_0 ... U_N) to set(T) if a conversion exists from each U to T.
func (*SetType) SyntaxNode ¶
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*SetType) Traverse ¶
func (t *SetType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the optional type with the given traverser. This always fails.
type SplatExpression ¶
type SplatExpression struct { // The syntax node associated with the splat expression. Syntax *hclsyntax.SplatExpr // The tokens associated with the expression, if any. Tokens *syntax.SplatTokens // The expression being splatted. Source Expression // The expression applied to each element of the splat. Each Expression // The local variable definition associated with the current item being processed. This definition is not part of // a scope, and can only be referenced by an AnonSymbolExpr. Item *SplatVariable // contains filtered or unexported fields }
SplatExpression represents a semantically-analyzed splat expression.
func (*SplatExpression) Evaluate ¶
func (x *SplatExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*SplatExpression) GetLeadingTrivia ¶
func (x *SplatExpression) GetLeadingTrivia() syntax.TriviaList
func (*SplatExpression) GetTrailingTrivia ¶
func (x *SplatExpression) GetTrailingTrivia() syntax.TriviaList
func (*SplatExpression) HasLeadingTrivia ¶
func (x *SplatExpression) HasLeadingTrivia() bool
func (*SplatExpression) HasTrailingTrivia ¶
func (x *SplatExpression) HasTrailingTrivia() bool
func (*SplatExpression) NodeTokens ¶
func (x *SplatExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the splat expression.
func (*SplatExpression) SetLeadingTrivia ¶
func (x *SplatExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*SplatExpression) SetTrailingTrivia ¶
func (x *SplatExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*SplatExpression) SyntaxNode ¶
func (x *SplatExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the splat expression.
func (*SplatExpression) Type ¶
func (x *SplatExpression) Type() Type
Type returns the type of the splat expression.
func (*SplatExpression) Typecheck ¶
func (x *SplatExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type SplatVariable ¶
type SplatVariable struct { Variable // contains filtered or unexported fields }
func (*SplatVariable) Value ¶
func (v *SplatVariable) Value(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
type StaticFunctionSignature ¶
type StaticFunctionSignature struct { // The function's fixed parameters. Parameters []Parameter // The function's variadic parameter, if any. Any arguments that follow a function's fixed arguments must be // assignable to this parameter. VarargsParameter *Parameter // The return type of the function. ReturnType Type // Determines whether the input bag should be treated as a single argument or as multiple arguments. MultiArgumentInputs bool }
StaticFunctionSignature records the parameters and return type of a function.
func (StaticFunctionSignature) GetSignature ¶
func (fs StaticFunctionSignature) GetSignature(arguments []Expression) (StaticFunctionSignature, hcl.Diagnostics)
GetSignature returns the static signature itself.
type TemplateExpression ¶
type TemplateExpression struct { // The syntax node associated with the template expression. Syntax *hclsyntax.TemplateExpr // The tokens associated with the expression, if any. Tokens *syntax.TemplateTokens // The parts of the template expression. Parts []Expression // contains filtered or unexported fields }
TemplateExpression represents a semantically-analyzed template expression.
func (*TemplateExpression) Evaluate ¶
func (x *TemplateExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*TemplateExpression) GetLeadingTrivia ¶
func (x *TemplateExpression) GetLeadingTrivia() syntax.TriviaList
func (*TemplateExpression) GetTrailingTrivia ¶
func (x *TemplateExpression) GetTrailingTrivia() syntax.TriviaList
func (*TemplateExpression) HasLeadingTrivia ¶
func (x *TemplateExpression) HasLeadingTrivia() bool
func (*TemplateExpression) HasTrailingTrivia ¶
func (x *TemplateExpression) HasTrailingTrivia() bool
func (*TemplateExpression) NodeTokens ¶
func (x *TemplateExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the template expression.
func (*TemplateExpression) SetLeadingTrivia ¶
func (x *TemplateExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*TemplateExpression) SetTrailingTrivia ¶
func (x *TemplateExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*TemplateExpression) SyntaxNode ¶
func (x *TemplateExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the template expression.
func (*TemplateExpression) Type ¶
func (x *TemplateExpression) Type() Type
Type returns the type of the template expression.
func (*TemplateExpression) Typecheck ¶
func (x *TemplateExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type TemplateJoinExpression ¶
type TemplateJoinExpression struct { // The syntax node associated with the template join expression. Syntax *hclsyntax.TemplateJoinExpr // The tuple being joined. Tuple Expression // contains filtered or unexported fields }
TemplateJoinExpression represents a semantically-analyzed template join expression.
func (*TemplateJoinExpression) Evaluate ¶
func (x *TemplateJoinExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*TemplateJoinExpression) Format ¶
func (x *TemplateJoinExpression) Format(f fmt.State, c rune)
func (*TemplateJoinExpression) GetLeadingTrivia ¶
func (x *TemplateJoinExpression) GetLeadingTrivia() syntax.TriviaList
func (*TemplateJoinExpression) GetTrailingTrivia ¶
func (x *TemplateJoinExpression) GetTrailingTrivia() syntax.TriviaList
func (*TemplateJoinExpression) HasLeadingTrivia ¶
func (x *TemplateJoinExpression) HasLeadingTrivia() bool
func (*TemplateJoinExpression) HasTrailingTrivia ¶
func (x *TemplateJoinExpression) HasTrailingTrivia() bool
func (*TemplateJoinExpression) NodeTokens ¶
func (x *TemplateJoinExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the template join expression.
func (*TemplateJoinExpression) SetLeadingTrivia ¶
func (x *TemplateJoinExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*TemplateJoinExpression) SetTrailingTrivia ¶
func (x *TemplateJoinExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*TemplateJoinExpression) SyntaxNode ¶
func (x *TemplateJoinExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the template join expression.
func (*TemplateJoinExpression) Type ¶
func (x *TemplateJoinExpression) Type() Type
Type returns the type of the template join expression.
func (*TemplateJoinExpression) Typecheck ¶
func (x *TemplateJoinExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type Traversable ¶
type Traversable interface { // Traverse attempts to traverse the receiver using the given traverser. Traverse(t hcl.Traverser) (Traversable, hcl.Diagnostics) }
Traversable represents an entity that can be traversed by an HCL2 traverser.
type TupleConsExpression ¶
type TupleConsExpression struct { // The syntax node associated with the tuple construction expression. Syntax *hclsyntax.TupleConsExpr // The tokens associated with the expression, if any. Tokens *syntax.TupleConsTokens // The elements of the tuple. Expressions []Expression // contains filtered or unexported fields }
TupleConsExpression represents a semantically-analyzed tuple construction expression.
func (*TupleConsExpression) Evaluate ¶
func (x *TupleConsExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*TupleConsExpression) GetLeadingTrivia ¶
func (x *TupleConsExpression) GetLeadingTrivia() syntax.TriviaList
func (*TupleConsExpression) GetTrailingTrivia ¶
func (x *TupleConsExpression) GetTrailingTrivia() syntax.TriviaList
func (*TupleConsExpression) HasLeadingTrivia ¶
func (x *TupleConsExpression) HasLeadingTrivia() bool
func (*TupleConsExpression) HasTrailingTrivia ¶
func (x *TupleConsExpression) HasTrailingTrivia() bool
func (*TupleConsExpression) NodeTokens ¶
func (x *TupleConsExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the tuple construction expression.
func (*TupleConsExpression) SetLeadingTrivia ¶
func (x *TupleConsExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*TupleConsExpression) SetTrailingTrivia ¶
func (x *TupleConsExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*TupleConsExpression) SyntaxNode ¶
func (x *TupleConsExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the tuple construction expression.
func (*TupleConsExpression) Type ¶
func (x *TupleConsExpression) Type() Type
Type returns the type of the tuple construction expression.
func (*TupleConsExpression) Typecheck ¶
func (x *TupleConsExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type TupleType ¶
type TupleType struct { // ElementTypes are the types of the tuple's elements. ElementTypes []Type // contains filtered or unexported fields }
TupleType represents values that are a sequence of independently-typed elements.
func (*TupleType) AssignableFrom ¶
AssignableFrom returns true if this type is assignable from the indicated source type..
func (*TupleType) ConversionFrom ¶
func (t *TupleType) ConversionFrom(src Type) ConversionKind
func (*TupleType) Equals ¶
Equals returns true if this type has the same identity as the given type.
func (*TupleType) SyntaxNode ¶
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*TupleType) Traverse ¶
func (t *TupleType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the tuple type with the given traverser. This always fails.
type Type ¶
type Type interface { fmt.Stringer Definition Equals(other Type) bool AssignableFrom(src Type) bool ConversionFrom(src Type) ConversionKind Pretty() pretty.Formatter // contains filtered or unexported methods }
Type represents a datatype in the Codeinfra Schema. Types created by this package are identical if they are equal values.
func GetTraversableType ¶
func GetTraversableType(t Traversable) Type
GetTraversableType returns the type of the given Traversable: - If the Traversable is a TypedTraversable, this returns t.Type() - If the Traversable is a Type, this returns t - Otherwise, this returns DynamicType
func GetTraverserKey ¶
GetTraverserKey extracts the value and type of the key associated with the given traverser.
func NewOptionalType ¶
NewOptionalType returns a new union(T, None).
func NewTupleType ¶
NewTupleType creates a new tuple type with the given element types.
func NewUnionType ¶
NewUnionType creates a new union type with the given element types. Any element types that are union types are replaced with their element types.
func NewUnionTypeAnnotated ¶
NewUnionTypeAnnotated creates a new union type with the given element types and annotations. NewUnionTypeAnnotated enforces 3 properties on the returned type: 1. Any element types that are union types are replaced with their element types. 2. Any duplicate types are removed. 3. Unions have have more then 1 type. If only a single type is left after (1) and (2), it is returned as is.
func ResolveOutputs ¶
ResolveOutputs recursively replaces all output(T) and promise(T) types in the input type with their element type.
func ResolvePromises ¶
ResolvePromises recursively replaces all promise(T) types in the input type with their element type.
type TypedTraversable ¶
type TypedTraversable interface { Traversable Type() Type }
TypedTraversable is a Traversable that has an associated type.
type UnaryOpExpression ¶
type UnaryOpExpression struct { // The syntax node associated with the unary operation. Syntax *hclsyntax.UnaryOpExpr // The tokens associated with the expression, if any. Tokens *syntax.UnaryOpTokens // The operation. Operation *hclsyntax.Operation // The operand of the operation. Operand Expression // contains filtered or unexported fields }
UnaryOpExpression represents a semantically-analyzed unary operation.
func (*UnaryOpExpression) Evaluate ¶
func (x *UnaryOpExpression) Evaluate(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics)
func (*UnaryOpExpression) GetLeadingTrivia ¶
func (x *UnaryOpExpression) GetLeadingTrivia() syntax.TriviaList
func (*UnaryOpExpression) GetTrailingTrivia ¶
func (x *UnaryOpExpression) GetTrailingTrivia() syntax.TriviaList
func (*UnaryOpExpression) HasLeadingTrivia ¶
func (x *UnaryOpExpression) HasLeadingTrivia() bool
func (*UnaryOpExpression) HasTrailingTrivia ¶
func (x *UnaryOpExpression) HasTrailingTrivia() bool
func (*UnaryOpExpression) NodeTokens ¶
func (x *UnaryOpExpression) NodeTokens() syntax.NodeTokens
NodeTokens returns the tokens associated with the unary operation.
func (*UnaryOpExpression) OperandType ¶
func (x *UnaryOpExpression) OperandType() Type
OperandType returns the operand type of the unary operation.
func (*UnaryOpExpression) SetLeadingTrivia ¶
func (x *UnaryOpExpression) SetLeadingTrivia(t syntax.TriviaList)
func (*UnaryOpExpression) SetTrailingTrivia ¶
func (x *UnaryOpExpression) SetTrailingTrivia(t syntax.TriviaList)
func (*UnaryOpExpression) SyntaxNode ¶
func (x *UnaryOpExpression) SyntaxNode() hclsyntax.Node
SyntaxNode returns the syntax node associated with the unary operation.
func (*UnaryOpExpression) Type ¶
func (x *UnaryOpExpression) Type() Type
Type returns the type of the unary operation.
func (*UnaryOpExpression) Typecheck ¶
func (x *UnaryOpExpression) Typecheck(typecheckOperands bool) hcl.Diagnostics
type UnionType ¶
type UnionType struct { // ElementTypes are the allowable types for the union type. ElementTypes []Type // Annotations records any annotations associated with the object type. Annotations []interface{} // contains filtered or unexported fields }
UnionType represents values that may be any one of a specified set of types.
func (*UnionType) AssignableFrom ¶
AssignableFrom returns true if this type is assignable from the indicated source type. A union(T_0, ..., T_N) from values of type union(U_0, ..., U_M) where all of U_0 through U_M are assignable to some type in (T_0, ..., T_N) and V where V is assignable to at least one of (T_0, ..., T_N).
func (*UnionType) ConversionFrom ¶
func (t *UnionType) ConversionFrom(src Type) ConversionKind
ConversionFrom returns the kind of conversion (if any) that is possible from the source type to this type. A union type is convertible from a source type if any of its elements are convertible from the source type. If any element type is safely convertible, the conversion is safe; if no element is safely convertible but some element is unsafely convertible, the conversion is unsafe.
func (*UnionType) Equals ¶
Equals returns true if this type has the same identity as the given type.
func (*UnionType) SyntaxNode ¶
SyntaxNode returns the syntax node for the type. This is always syntax.None.
func (*UnionType) Traverse ¶
func (t *UnionType) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the union type with the given traverser. This always fails.
type ValueTraversable ¶
type ValueTraversable interface { Traversable Value(context *hcl.EvalContext) (cty.Value, hcl.Diagnostics) }
ValueTraversable is a Traversable that has an associated value.
type Variable ¶
type Variable struct { // The syntax node associated with the variable definition, if any. Syntax hclsyntax.Node // The name of the variable. Name string // The type of the variable. VariableType Type }
A Variable is a traversable, typed definition that represents a named value.
func (*Variable) SyntaxNode ¶
SyntaxNode returns the variable's syntax node or syntax.None.
func (*Variable) Traverse ¶
func (v *Variable) Traverse(traverser hcl.Traverser) (Traversable, hcl.Diagnostics)
Traverse attempts to traverse the variable's type.
Source Files ¶
- attribute.go
- binder_expression.go
- block.go
- body.go
- diagnostics.go
- expression.go
- functions.go
- printer.go
- scope.go
- traversable.go
- type.go
- type_collection.go
- type_const.go
- type_enum.go
- type_eventuals.go
- type_list.go
- type_map.go
- type_none.go
- type_object.go
- type_opaque.go
- type_output.go
- type_promise.go
- type_scope.go
- type_set.go
- type_tuple.go
- type_union.go
- utilities.go
- visitor.go