Documentation
¶
Index ¶
- Variables
- func NewDiagnosticWriter(w io.Writer, files []*File, width uint, color bool) hcl.DiagnosticWriter
- func OperationTokenType(operation *hclsyntax.Operation) hclsyntax.TokenType
- type AttributeTokens
- type BinaryOpTokens
- type BlockTokens
- type BodyTokens
- type BracketTraverserTokens
- type Comment
- type ConditionalTokens
- type DotTraverserTokens
- type File
- type ForTokens
- func (t *ForTokens) GetArrow() *Token
- func (t *ForTokens) GetClose() Token
- func (t *ForTokens) GetColon() Token
- func (t *ForTokens) GetComma() *Token
- func (t *ForTokens) GetFor() Token
- func (t *ForTokens) GetGroup() *Token
- func (t *ForTokens) GetIf() *Token
- func (t *ForTokens) GetIn() Token
- func (t *ForTokens) GetKey() *Token
- func (t *ForTokens) GetOpen() Token
- func (t *ForTokens) GetValue() Token
- type FunctionCallTokens
- type IndexTokens
- type LiteralValueTokens
- type NodeTokens
- type ObjectConsItemTokens
- type ObjectConsTokens
- type Parser
- type RelativeTraversalTokens
- type ScopeTraversalTokens
- type SplatTokens
- type TemplateConditionalTokens
- type TemplateDelimiter
- type TemplateForTokens
- type TemplateTokens
- type Token
- type TokenMap
- type TraverserTokens
- type Trivia
- type TriviaList
- type TupleConsTokens
- type UnaryOpTokens
- type Whitespace
Constants ¶
This section is empty.
Variables ¶
var None hclsyntax.Node = &hclsyntax.Body{}
None is an HCL syntax node that can be used when a syntax node is required but none is appropriate.
Functions ¶
func NewDiagnosticWriter ¶
NewDiagnosticWriter creates a new diagnostic writer for the given list of HCL2 files.
Types ¶
type AttributeTokens ¶
AttributeTokens records the tokens associated with an *hclsyntax.Attribute.
func NewAttributeTokens ¶ added in v1.14.1
func NewAttributeTokens(name string) *AttributeTokens
func (*AttributeTokens) GetEquals ¶ added in v1.14.1
func (t *AttributeTokens) GetEquals() Token
func (*AttributeTokens) GetName ¶ added in v1.14.1
func (t *AttributeTokens) GetName() Token
type BinaryOpTokens ¶
type BinaryOpTokens struct {
Operator Token
}
BinaryOpTokens records the tokens associated with an *hclsyntax.BinaryOpExpr.
func NewBinaryOpTokens ¶ added in v1.14.1
func NewBinaryOpTokens(operation *hclsyntax.Operation) *BinaryOpTokens
func (*BinaryOpTokens) GetOperator ¶ added in v1.14.1
func (t *BinaryOpTokens) GetOperator() Token
type BlockTokens ¶
BlockTokens records the tokens associated with an *hclsyntax.Block.
func NewBlockTokens ¶ added in v1.14.1
func NewBlockTokens(typ string, labels ...string) *BlockTokens
func (*BlockTokens) GetCloseBrace ¶ added in v1.14.1
func (t *BlockTokens) GetCloseBrace() Token
func (*BlockTokens) GetLabels ¶ added in v1.14.1
func (t *BlockTokens) GetLabels() []Token
func (*BlockTokens) GetOpenBrace ¶ added in v1.14.1
func (t *BlockTokens) GetOpenBrace() Token
func (*BlockTokens) GetType ¶ added in v1.14.1
func (t *BlockTokens) GetType() Token
type BodyTokens ¶
type BodyTokens struct {
EndOfFile *Token
}
BodyTokens records the tokens associated with an *hclsyntax.Body.
func (*BodyTokens) GetEndOfFile ¶ added in v1.14.1
func (t *BodyTokens) GetEndOfFile() *Token
type BracketTraverserTokens ¶
BracketTraverserTokens records the tokens associated with a bracketed traverser (i.e. '[' <index> ']').
func NewBracketTraverserTokens ¶ added in v1.14.1
func NewBracketTraverserTokens(index string) *BracketTraverserTokens
func (*BracketTraverserTokens) GetCloseBracket ¶ added in v1.14.1
func (t *BracketTraverserTokens) GetCloseBracket() Token
func (*BracketTraverserTokens) GetIndex ¶ added in v1.14.1
func (t *BracketTraverserTokens) GetIndex() Token
func (*BracketTraverserTokens) GetOpenBracket ¶ added in v1.14.1
func (t *BracketTraverserTokens) GetOpenBracket() Token
type Comment ¶
type Comment struct { // Lines contains the lines of the comment without leading comment characters or trailing newlines. Lines []string // contains filtered or unexported fields }
Comment is a piece of trivia that represents a line or block comment in a source file.
type ConditionalTokens ¶
ConditionalTokens records the tokens associated with an *hclsyntax.ConditionalExpr of the form "a ? t : f".
func NewConditionalTokens ¶ added in v1.14.1
func NewConditionalTokens() *ConditionalTokens
func (*ConditionalTokens) GetColon ¶ added in v1.14.1
func (t *ConditionalTokens) GetColon() Token
func (*ConditionalTokens) GetQuestionMark ¶ added in v1.14.1
func (t *ConditionalTokens) GetQuestionMark() Token
type DotTraverserTokens ¶
DotTraverserTokens records the tokens associated with dotted traverser (i.e. '.' <attr>).
func NewDotTraverserTokens ¶ added in v1.14.1
func NewDotTraverserTokens(index string) *DotTraverserTokens
func (*DotTraverserTokens) GetDot ¶ added in v1.14.1
func (t *DotTraverserTokens) GetDot() Token
func (*DotTraverserTokens) GetIndex ¶ added in v1.14.1
func (t *DotTraverserTokens) GetIndex() Token
type File ¶
type File struct { Name string // The name of the file. Body *hclsyntax.Body // The body of the parsed file. Bytes []byte // The raw bytes of the source file. Tokens TokenMap // A map from syntax nodes to token information. }
File represents a single parsed HCL2 source file.
type ForTokens ¶
type ForTokens struct { Open Token For Token Key *Token Comma *Token Value Token In Token Colon Token Arrow *Token Group *Token If *Token Close Token }
ForTokens records the tokens associated with an *hclsyntax.ForExpr.
func NewForTokens ¶ added in v1.14.1
type FunctionCallTokens ¶
FunctionCallTokens records the tokens associated with an *hclsyntax.FunctionCallExpr.
func NewFunctionCallTokens ¶ added in v1.14.1
func NewFunctionCallTokens(name string, argCount int) *FunctionCallTokens
func (*FunctionCallTokens) GetCloseParen ¶ added in v1.14.1
func (t *FunctionCallTokens) GetCloseParen() Token
func (*FunctionCallTokens) GetCommas ¶ added in v1.14.1
func (t *FunctionCallTokens) GetCommas() []Token
func (*FunctionCallTokens) GetName ¶ added in v1.14.1
func (t *FunctionCallTokens) GetName() Token
func (*FunctionCallTokens) GetOpenParen ¶ added in v1.14.1
func (t *FunctionCallTokens) GetOpenParen() Token
type IndexTokens ¶
IndexTokens records the tokens associated with an *hclsyntax.IndexExpr.
func NewIndexTokens ¶ added in v1.14.1
func NewIndexTokens() *IndexTokens
func (*IndexTokens) GetCloseBracket ¶ added in v1.14.1
func (t *IndexTokens) GetCloseBracket() Token
func (*IndexTokens) GetOpenBracket ¶ added in v1.14.1
func (t *IndexTokens) GetOpenBracket() Token
type LiteralValueTokens ¶
type LiteralValueTokens struct {
Value []Token
}
LiteralValueTokens records the tokens associated with an *hclsyntax.LiteralValueExpr.
func NewLiteralValueTokens ¶ added in v1.14.1
func NewLiteralValueTokens(tokens ...Token) *LiteralValueTokens
func (*LiteralValueTokens) GetValue ¶ added in v1.14.1
func (t *LiteralValueTokens) GetValue() []Token
type NodeTokens ¶
type NodeTokens interface {
// contains filtered or unexported methods
}
NodeTokens is a closed interface that is used to represent arbitrary *Tokens types in this package.
type ObjectConsItemTokens ¶
ObjectConsItemTokens records the tokens associated with an hclsyntax.ObjectConsItem.
type ObjectConsTokens ¶
type ObjectConsTokens struct { OpenBrace Token Items []ObjectConsItemTokens CloseBrace Token }
ObjectConsTokens records the tokens associated with an *hclsyntax.ObjectConsExpr.
func NewObjectConsTokens ¶ added in v1.14.1
func NewObjectConsTokens(itemCount int) *ObjectConsTokens
func (*ObjectConsTokens) GetCloseBrace ¶ added in v1.14.1
func (t *ObjectConsTokens) GetCloseBrace() Token
func (*ObjectConsTokens) GetItems ¶ added in v1.14.1
func (t *ObjectConsTokens) GetItems() []ObjectConsItemTokens
func (*ObjectConsTokens) GetOpenBrace ¶ added in v1.14.1
func (t *ObjectConsTokens) GetOpenBrace() Token
type Parser ¶
type Parser struct { Files []*File // The parsed files. Diagnostics hcl.Diagnostics // The diagnostics, if any, produced during parsing. // contains filtered or unexported fields }
Parser is a parser for HCL2 source files.
func (*Parser) NewDiagnosticWriter ¶
NewDiagnosticWriter creates a new diagnostic writer for the files parsed by the parser.
type RelativeTraversalTokens ¶
type RelativeTraversalTokens struct {
Traversal []TraverserTokens
}
RelativeTraversalTokens records the tokens associated with an *hclsyntax.RelativeTraversalExpr.
func NewRelativeTraversalTokens ¶ added in v1.14.1
func NewRelativeTraversalTokens(traversers ...TraverserTokens) *RelativeTraversalTokens
func (*RelativeTraversalTokens) GetTraversal ¶ added in v1.14.1
func (t *RelativeTraversalTokens) GetTraversal() []TraverserTokens
type ScopeTraversalTokens ¶
type ScopeTraversalTokens struct { Root Token Traversal []TraverserTokens }
ScopeTraversalTokens records the tokens associated with an *hclsyntax.ScopeTraversalExpr.
func NewScopeTraversalTokens ¶ added in v1.14.1
func NewScopeTraversalTokens(root string, traversers ...TraverserTokens) *ScopeTraversalTokens
func (*ScopeTraversalTokens) GetRoot ¶ added in v1.14.1
func (t *ScopeTraversalTokens) GetRoot() Token
func (*ScopeTraversalTokens) GetTraversal ¶ added in v1.14.1
func (t *ScopeTraversalTokens) GetTraversal() []TraverserTokens
type SplatTokens ¶
SplatTokens records the tokens associated with an *hclsyntax.SplatExpr.
func NewSplatTokens ¶ added in v1.14.1
func NewSplatTokens(dotted bool) *SplatTokens
func (*SplatTokens) GetClose ¶ added in v1.14.1
func (t *SplatTokens) GetClose() *Token
func (*SplatTokens) GetOpen ¶ added in v1.14.1
func (t *SplatTokens) GetOpen() Token
func (*SplatTokens) GetStar ¶ added in v1.14.1
func (t *SplatTokens) GetStar() Token
type TemplateConditionalTokens ¶ added in v1.14.1
type TemplateConditionalTokens struct { OpenIf Token If Token CloseIf Token OpenElse *Token Else *Token CloseElse *Token OpenEndif Token Endif Token CloseEndif Token }
TemplateConditionalTokens records the tokens associated with an *hclsyntax.ConditionalExpr inside a template expression.
func NewTemplateConditionalTokens ¶ added in v1.14.1
func NewTemplateConditionalTokens(hasElse bool) *TemplateConditionalTokens
type TemplateDelimiter ¶ added in v1.14.1
type TemplateDelimiter struct { // Type is the type of the delimiter (e.g. hclsyntax.TokenTemplateInterp) Type hclsyntax.TokenType // contains filtered or unexported fields }
TemplateDelimiter is a piece of trivia that represents a token that demarcates an interpolation or control sequence inside of a template.
func (TemplateDelimiter) Bytes ¶ added in v1.14.1
func (t TemplateDelimiter) Bytes() []byte
Bytes returns the raw bytes that comprise the delimiter.
func (TemplateDelimiter) Range ¶ added in v1.14.1
func (t TemplateDelimiter) Range() hcl.Range
Range returns the range of the delimiter in the source file.
type TemplateForTokens ¶ added in v1.14.1
type TemplateForTokens struct { OpenFor Token For Token Key *Token Comma *Token Value Token In Token CloseFor Token OpenEndfor Token Endfor Token CloseEndfor Token }
TemplateForTokens records the tokens associated with an *hclsyntax.ForExpr inside a template.
func NewTemplateForTokens ¶ added in v1.14.1
func NewTemplateForTokens(keyVariable, valueVariable string) *TemplateForTokens
func (*TemplateForTokens) GetComma ¶ added in v1.14.1
func (t *TemplateForTokens) GetComma() *Token
func (*TemplateForTokens) GetEndfor ¶ added in v1.14.1
func (t *TemplateForTokens) GetEndfor() Token
func (*TemplateForTokens) GetFor ¶ added in v1.14.1
func (t *TemplateForTokens) GetFor() Token
func (*TemplateForTokens) GetIn ¶ added in v1.14.1
func (t *TemplateForTokens) GetIn() Token
func (*TemplateForTokens) GetKey ¶ added in v1.14.1
func (t *TemplateForTokens) GetKey() *Token
func (*TemplateForTokens) GetValue ¶ added in v1.14.1
func (t *TemplateForTokens) GetValue() Token
type TemplateTokens ¶
TemplateTokens records the tokens associated with an *hclsyntax.TemplateExpr.
func NewTemplateTokens ¶ added in v1.14.1
func NewTemplateTokens() *TemplateTokens
func (*TemplateTokens) GetClose ¶ added in v1.14.1
func (t *TemplateTokens) GetClose() Token
func (*TemplateTokens) GetOpen ¶ added in v1.14.1
func (t *TemplateTokens) GetOpen() Token
type Token ¶
type Token struct { Raw hclsyntax.Token LeadingTrivia TriviaList TrailingTrivia TriviaList }
Token represents an HCL2 syntax token with attached leading trivia.
func (Token) AllTrivia ¶ added in v1.14.1
func (t Token) AllTrivia() TriviaList
type TokenMap ¶
type TokenMap interface { ForNode(n hclsyntax.Node) NodeTokens // contains filtered or unexported methods }
A TokenMap is used to map from syntax nodes to information about their tokens and leading whitespace/comments.
func NewTokenMapForFiles ¶
NewTokenMapForFiles creates a new token map that can be used to look up tokens for nodes in any of the given files.
func ParseExpression ¶
func ParseExpression(expression, filename string, start hcl.Pos) (hclsyntax.Expression, TokenMap, hcl.Diagnostics)
ParseExpression attempts to parse the given string as an HCL2 expression.
type TraverserTokens ¶
type TraverserTokens interface { GetIndex() Token // contains filtered or unexported methods }
TraverserTokens is a closed interface implemented by DotTraverserTokens and BracketTraverserTokens
type Trivia ¶
type Trivia interface { // Range returns the range of the trivia in the source file. Range() hcl.Range // Bytes returns the raw bytes that comprise the trivia. Bytes() []byte // contains filtered or unexported methods }
Trivia represents bytes in a source file that are not syntactically meaningful. This includes whitespace and comments.
type TriviaList ¶ added in v1.14.1
type TriviaList []Trivia
TriviaList is a list of trivia.
func (TriviaList) CollapseWhitespace ¶ added in v1.14.1
func (trivia TriviaList) CollapseWhitespace() TriviaList
type TupleConsTokens ¶
TupleConsTokens records the tokens associated with an *hclsyntax.TupleConsExpr.
func NewTupleConsTokens ¶ added in v1.14.1
func NewTupleConsTokens(elementCount int) *TupleConsTokens
func (*TupleConsTokens) GetCloseBracket ¶ added in v1.14.1
func (t *TupleConsTokens) GetCloseBracket() Token
func (*TupleConsTokens) GetCommas ¶ added in v1.14.1
func (t *TupleConsTokens) GetCommas() []Token
func (*TupleConsTokens) GetOpenBracket ¶ added in v1.14.1
func (t *TupleConsTokens) GetOpenBracket() Token
type UnaryOpTokens ¶
type UnaryOpTokens struct {
Operator Token
}
UnaryOpTokens records the tokens associated with an *hclsyntax.UnaryOpExpr.
func NewUnaryOpTokens ¶ added in v1.14.1
func NewUnaryOpTokens(operation *hclsyntax.Operation) *UnaryOpTokens
func (*UnaryOpTokens) GetOperator ¶ added in v1.14.1
func (t *UnaryOpTokens) GetOperator() Token
type Whitespace ¶
type Whitespace struct {
// contains filtered or unexported fields
}
Whitespace is a piece of trivia that represents a sequence of whitespace characters in a source file.
func NewWhitespace ¶ added in v1.14.1
func NewWhitespace(bytes ...byte) Whitespace
NewWhitespace returns a new piece of whitespace trivia with the given contents.
func (Whitespace) Bytes ¶
func (w Whitespace) Bytes() []byte
Bytes returns the raw bytes that comprise the whitespace.
func (Whitespace) Range ¶
func (w Whitespace) Range() hcl.Range
Range returns the range of the whitespace in the source file.