Documentation
¶
Overview ¶
Package printer implements printing of AST nodes.
Index ¶
Constants ¶
const (
DbgFlagAll = 1
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CommentedNode ¶
type CommentedNode struct {
Node any // *ast.File, or ast.Expr, ast.Decl, ast.Spec, or ast.Stmt
Comments []*ast.CommentGroup
}
A CommentedNode bundles an AST node and corresponding comments. It may be provided as argument to any of the Fprint functions.
type CommentedNodes ¶ added in v1.6.0
type CommentedNodes struct {
Node any // *ast.File, or ast.Expr, ast.Decl, ast.Spec, or ast.Stmt
CommentedStmts map[ast.Stmt]*ast.CommentGroup // statements with their leading comments
}
CommentedNodes holds an AST node and a map of statements with their leading comments. This allows attaching diagnostic comments to specific statements during code generation.
type Config ¶
type Config struct {
Mode Mode // default: 0
Tabwidth int // default: 8
Indent int // default: 0 (all code is indented at least by this much)
}
A Config node controls the output of Fprint.
func (*Config) Fprint ¶
Fprint "pretty-prints" an AST node to output for a given configuration cfg. Position information is interpreted relative to the file set fset. The node type must be *ast.File, *CommentedNode, *CommentedNodes, []ast.Decl, []ast.Stmt, or assignment-compatible to ast.Expr, ast.Decl, ast.Spec, or ast.Stmt.
type NewlineStmt ¶
NewlineStmt represents a statement that formats as a newline