decorator

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2018 License: MIT Imports: 10 Imported by: 210

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decorate

func Decorate(fset *token.FileSet, n ast.Node) dst.Node

Decorate decorates an ast.Node and returns a dst.Node.

func DecorateFile added in v0.1.0

func DecorateFile(fset *token.FileSet, f *ast.File) *dst.File

Decorate decorates a *ast.File and returns a *dst.File.

func Fprint

func Fprint(w io.Writer, f *dst.File) error

Fprint uses format.Node to print a *dst.File to a writer

func Parse

func Parse(src interface{}) (*dst.File, error)

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

func ParseExpr(x string) (dst.Expr, error)

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.

func ParseFile added in v0.1.0

func ParseFile(fset *token.FileSet, filename string, src interface{}, mode parser.Mode) (*dst.File, error)

ParseFile uses parser.ParseFile to parse and decorate a Go source file.

func Print

func Print(f *dst.File) error

Print uses format.Node to print a *dst.File to stdout

func Restore

func Restore(file *dst.File) (*token.FileSet, *ast.File)

Restore restores a *dst.File to a *token.FileSet and a *ast.File

Types

type AstMap added in v0.9.0

type AstMap struct {
	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
}

type Decorator added in v0.1.0

type Decorator struct {
	Map
	Filenames map[*dst.File]string // Source file names
	// contains filtered or unexported fields
}

func New added in v0.1.0

func New() *Decorator

New returns a new decorator.

func (*Decorator) Decorate added in v0.1.0

func (d *Decorator) Decorate(fset *token.FileSet, n ast.Node) dst.Node

Decorate decorates an ast.Node and returns a dst.Node

type DstMap added in v0.9.0

type DstMap struct {
	Nodes   map[ast.Node]dst.Node       // Mapping from ast to dst Nodes
	Objects map[*ast.Object]*dst.Object // Mapping from ast to dst Objects
	Scopes  map[*ast.Scope]*dst.Scope   // Mapping from ast to dst Scopes
}

type Map added in v0.9.0

type Map struct {
	Ast AstMap
	Dst DstMap
}

type Restorer added in v0.1.0

type Restorer struct {
	Map
	Fset *token.FileSet // Fset is the *token.FileSet in use. Set this to use a pre-existing FileSet.
}

func NewRestorer added in v0.1.0

func NewRestorer() *Restorer

NewRestorer creates a new Restorer

func (*Restorer) RestoreFile added in v0.1.0

func (r *Restorer) RestoreFile(name string, file *dst.File) *ast.File

RestoreFile restores a *dst.File to an *ast.File

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL