decorator

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 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

func DecorateFile added in v0.1.0

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

func Fprint

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

func Parse

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

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)

func ParseExpr added in v0.1.0

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

func ParseExprFrom added in v0.1.0

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

func ParseFile added in v0.1.0

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

func Print

func Print(f *dst.File) error

func Restore

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

Types

type CommentFragment

type CommentFragment struct {
	Text     string
	Pos      token.Pos
	Attached *DecorationFragment // where did we attach this comment in pass 1?
}

func (*CommentFragment) Position

func (v *CommentFragment) Position() token.Pos

type DecorationFragment

type DecorationFragment struct {
	Node ast.Node
	Name string
	Pos  token.Pos
}

func (*DecorationFragment) Position

func (v *DecorationFragment) Position() token.Pos

type Decorator added in v0.1.0

type Decorator struct {
	Nodes   map[ast.Node]dst.Node
	Scopes  map[*ast.Scope]*dst.Scope
	Objects map[*ast.Object]*dst.Object
	Info    *Info
	// contains filtered or unexported fields
}

func New added in v0.1.0

func New() *Decorator

func (*Decorator) Decorate added in v0.1.0

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

type Fragger

type Fragger struct {
	Fragments []Fragment
	// contains filtered or unexported fields
}

func (*Fragger) AddComment

func (f *Fragger) AddComment(text string, pos token.Pos)

func (*Fragger) AddDecoration

func (f *Fragger) AddDecoration(n ast.Node, name string, pos token.Pos)

func (*Fragger) AddNewline

func (f *Fragger) AddNewline(pos token.Pos, empty bool)

func (*Fragger) AddString

func (f *Fragger) AddString(n ast.Node, s string, pos token.Pos)

func (*Fragger) AddToken

func (f *Fragger) AddToken(n ast.Node, t token.Token, pos token.Pos)

func (*Fragger) Fragment

func (f *Fragger) Fragment(fset *token.FileSet, node ast.Node)
func (f *Fragger) Link() (space, after map[ast.Node]dst.SpaceType, decorations map[ast.Node]map[string][]string)

func (*Fragger) ProcessNode

func (f *Fragger) ProcessNode(n ast.Node)

type Fragment

type Fragment interface {
	Position() token.Pos
}

type Info added in v0.1.0

type Info struct {
	Filenames map[*dst.File]string
}

type NewlineFragment

type NewlineFragment struct {
	Pos      token.Pos
	Empty    bool                // true if this newline is an empty line (e.g. follows a "//" comment or "\n")
	Attached *DecorationFragment // where did we attach this comment in pass 1?
}

func (*NewlineFragment) Position

func (v *NewlineFragment) Position() token.Pos

type Restorer added in v0.1.0

type Restorer struct {
	Fset    *token.FileSet
	Nodes   map[dst.Node]ast.Node
	Objects map[*dst.Object]*ast.Object
	Scopes  map[*dst.Scope]*ast.Scope
}

func NewRestorer added in v0.1.0

func NewRestorer() *Restorer

func (*Restorer) RestoreFile added in v0.1.0

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

type StringFragment

type StringFragment struct {
	Node   ast.Node
	String string
	Pos    token.Pos
}

func (*StringFragment) Position

func (v *StringFragment) Position() token.Pos

type TokenFragment

type TokenFragment struct {
	Node  ast.Node
	Token token.Token
	Pos   token.Pos
}

func (*TokenFragment) Position

func (v *TokenFragment) Position() token.Pos

Jump to

Keyboard shortcuts

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