Documentation ¶
Overview ¶
The sym package provides a way to iterate over and change the symbols in Go source files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { ChangedFiles map[string]*ast.File // FileSet holds the fileset used when importing packages. FileSet *token.FileSet // Logf is used to print warning messages. // If it is nil, no warning messages will be printed. Logf func(pos token.Pos, f string, a ...interface{}) // contains filtered or unexported fields }
Context holds the context for IterateSyms.
func NewContext ¶
func NewContext() *Context
func (*Context) Import ¶
Import imports and parses the package with the given path. It returns nil if it fails.
func (*Context) IterateSyms ¶
IterateSyms calls visitf for each identifier in the given file. If visitf returns false, the iteration stops. If visitf changes info.Ident.Name, the file is added to ctxt.ChangedFiles.
type Info ¶
type Info struct { Pos token.Pos // position of symbol. Expr ast.Expr // expression for symbol (*ast.Ident or *ast.SelectorExpr) Ident *ast.Ident // identifier in parse tree (changing ident.Name changes the parse tree) ExprType types.Type // type of expression. ReferPos token.Pos // position of referred-to symbol. ReferObj *ast.Object // object referred to. Local bool // whether referred-to object is function-local. Universe bool // whether referred-to object is in universe. }
Info holds information about an identifier.
Click to show internal directories.
Click to hide internal directories.