Documentation ¶
Index ¶
- func Decorate(fset *token.FileSet, n ast.Node) dst.Node
- func DecorateFile(fset *token.FileSet, f *ast.File) *dst.File
- func Fprint(w io.Writer, f *dst.File) error
- func Parse(src interface{}) (*dst.File, error)
- func ParseDir(fset *token.FileSet, path string, filter func(os.FileInfo) bool, ...) (map[string]*dst.Package, error)
- func ParseExpr(x string) (dst.Expr, error)
- func ParseExprFrom(fset *token.FileSet, filename string, src interface{}, mode parser.Mode) (dst.Expr, error)
- func ParseFile(fset *token.FileSet, filename string, src interface{}, mode parser.Mode) (*dst.File, error)
- func Print(f *dst.File) error
- func Restore(file *dst.File) (*token.FileSet, *ast.File)
- type Decorator
- type Info
- type Restorer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecorateFile ¶ added in v0.1.0
Decorate decorates a *ast.File and returns a *dst.File.
func Parse ¶
Parse uses parser.ParseFile to parse and decorate a Go source file. The src parameter should be string, []byte, or io.Reader.
func ParseDir ¶ added in v0.1.0
func ParseDir(fset *token.FileSet, path string, filter func(os.FileInfo) bool, mode parser.Mode) (map[string]*dst.Package, error)
ParseDir uses parser.ParseDir to parse and decorate a directory containing Go source.
func ParseExpr ¶ added in v0.1.0
ParseExpr uses parser.ParseExpr to parse and decorate a Go expression. It should be noted that this is of limited use because comments are not parsed by parser.ParseExpr.
func ParseExprFrom ¶ added in v0.1.0
func ParseExprFrom(fset *token.FileSet, filename string, src interface{}, mode parser.Mode) (dst.Expr, error)
ParseExprFrom uses parser.ParseExprFrom to parse and decorate a Go expression. It should be noted that this is of limited use because comments are not parsed by parser.ParseExprFrom.
Types ¶
type Decorator ¶ added in v0.1.0
type Decorator struct { DstNodes map[ast.Node]dst.Node // Mapping from ast to dst Nodes DstScopes map[*ast.Scope]*dst.Scope // Mapping from ast to dst Scopes DstObjects map[*ast.Object]*dst.Object // Mapping from ast to dst Objects AstNodes map[dst.Node]ast.Node // Mapping from dst to ast Nodes AstScopes map[*dst.Scope]*ast.Scope // Mapping from dst to ast Scopes AstObjects map[*dst.Object]*ast.Object // Mapping from dst to ast Objects Info *Info // Info object containing source file names // contains filtered or unexported fields }
type Restorer ¶ added in v0.1.0
type Restorer struct { Fset *token.FileSet // Fset is the *token.FileSet in use. Set this to use a pre-existing FileSet. Nodes map[dst.Node]ast.Node // Mapping from dst to ast Nodes Objects map[*dst.Object]*ast.Object // Mapping from dst to ast Objects Scopes map[*dst.Scope]*ast.Scope // Mapping from dst to ast Scopes }
Click to show internal directories.
Click to hide internal directories.