Documentation
¶
Index ¶
- Constants
- Variables
- func CodeOf(fset *token.FileSet, f *ast.File, start, end token.Pos) string
- func NameOf(node Node) string
- type Node
- type NodeEnum
- type NodeSet
- func FromDir(fset *token.FileSet, path string, filter func(fs.FileInfo) bool, ...) (doc NodeSet, err error)
- func FromFSDir(fset *token.FileSet, fs parser.FileSystem, path string, ...) (doc NodeSet, err error)
- func FromFSFile(fset *token.FileSet, fs fsx.FileSystem, filename string, src any, ...) (doc NodeSet, err error)
- func FromFile(fset *token.FileSet, filename string, src any, mode parser.Mode) (doc NodeSet, err error)
- func Nodes(nodes ...Node) NodeSet
- func One__0(node Node) NodeSet
- func One__1(f *ast.File) NodeSet
- func One__2(pkg *ast.Package) NodeSet
- func (p NodeSet) Any() (ret NodeSet)
- func (p NodeSet) Arg(i int) NodeSet
- func (p NodeSet) AssignStmt() NodeSet
- func (p NodeSet) Body() NodeSet
- func (p NodeSet) Cache() NodeSet
- func (p NodeSet) CallExpr__0() NodeSet
- func (p NodeSet) CallExpr__1(name string) NodeSet
- func (p NodeSet) Child() NodeSet
- func (p NodeSet) Collect() (items []Node, err error)
- func (p NodeSet) CollectOne__0() (item Node, err error)
- func (p NodeSet) CollectOne__1(exactly bool) (item Node, err error)
- func (p NodeSet) CompositeLit__0() NodeSet
- func (p NodeSet) CompositeLit__1(name string) NodeSet
- func (p NodeSet) EltLen__0() (ret int, err error)
- func (p NodeSet) EltLen__1(exactly bool) (ret int, err error)
- func (p NodeSet) Elt__0(i int) NodeSet
- func (p NodeSet) Elt__1() NodeSet
- func (p NodeSet) Elt__2(name string) NodeSet
- func (p NodeSet) ExprStmt() NodeSet
- func (p NodeSet) ForEach(callback func(node NodeSet))
- func (p NodeSet) Fun() NodeSet
- func (p NodeSet) FuncDecl__0() NodeSet
- func (p NodeSet) FuncDecl__1(name string) NodeSet
- func (p NodeSet) Funcs() NodeSet
- func (p NodeSet) GenDecl__0(tok token.Token) NodeSet
- func (p NodeSet) Gop_Enum(callback func(node NodeSet))
- func (p NodeSet) Ident__0() (ret string, err error)
- func (p NodeSet) Ident__1(exactly bool) (ret string, err error)
- func (p NodeSet) ImportSpec() NodeSet
- func (p NodeSet) Match(match func(node Node) bool) (ret NodeSet)
- func (p NodeSet) Name() []string
- func (p NodeSet) Ok() bool
- func (p NodeSet) One() NodeSet
- func (p NodeSet) Positions__0() (ret []token.Pos, err error)
- func (p NodeSet) Positions__1(exactly bool) (ret []token.Pos, err error)
- func (p NodeSet) Rhs(i int) NodeSet
- func (p NodeSet) ToString(str func(node Node) string) (items []string)
- func (p NodeSet) TypeSpec() NodeSet
- func (p NodeSet) UnquotedStringElts__0() (ret []string, err error)
- func (p NodeSet) UnquotedStringElts__1(exactly bool) (ret []string, err error)
- func (p NodeSet) UnquotedString__0() (ret string, err error)
- func (p NodeSet) UnquotedString__1(exactly bool) (ret string, err error)
- func (p NodeSet) ValueSpec() NodeSet
- func (p NodeSet) Varg(i int) NodeSet
- func (p NodeSet) X() NodeSet
Constants ¶
const (
GopPackage = true
)
Variables ¶
var ( // ErrBreak - break ErrBreak = syscall.ELOOP // ErrNotFound - not found ErrNotFound = errors.New("not found") // ErrTooManyNodes - too may nodes ErrTooManyNodes = errors.New("too many nodes") // ErrUnexpectedNode - unexpected node ErrUnexpectedNode = errors.New("unexpected node") )
Functions ¶
Types ¶
type NodeSet ¶
NodeSet - node set
func FromDir ¶ added in v1.3.2
func FromDir( fset *token.FileSet, path string, filter func(fs.FileInfo) bool, mode parser.Mode) (doc NodeSet, err error)
FromDir calls ParseFile for all files with names ending in ".gop" in the directory specified by path and returns a map of package name -> package AST with all the packages found.
If filter != nil, only the files with fs.FileInfo entries passing through the filter (and ending in ".gop") are considered. The mode bits are passed to ParseFile unchanged. Position information is recorded in fset, which must not be nil.
If the directory couldn't be read, a nil map and the respective error are returned. If a parse error occurred, a non-nil but incomplete map and the first error encountered are returned.
func FromFSDir ¶ added in v1.3.2
func FromFSDir( fset *token.FileSet, fs parser.FileSystem, path string, filter func(fs.FileInfo) bool, mode parser.Mode) (doc NodeSet, err error)
FromFSDir calls ParseFile for all files with names ending in ".gop" in the directory specified by path and returns a map of package name -> package AST with all the packages found.
If filter != nil, only the files with fs.FileInfo entries passing through the filter (and ending in ".gop") are considered. The mode bits are passed to ParseFile unchanged. Position information is recorded in fset, which must not be nil.
If the directory couldn't be read, a nil map and the respective error are returned. If a parse error occurred, a non-nil but incomplete map and the first error encountered are returned.
func FromFSFile ¶ added in v1.3.2
func FromFSFile( fset *token.FileSet, fs fsx.FileSystem, filename string, src any, mode parser.Mode) (doc NodeSet, err error)
FromFSFile calls ParseFSFile for a single file and returns *ast.File node set.
func FromFile ¶ added in v1.3.2
func FromFile(fset *token.FileSet, filename string, src any, mode parser.Mode) (doc NodeSet, err error)
FromFile calls ParseFile for a single file and returns *ast.File node set.
func (NodeSet) AssignStmt ¶ added in v1.3.2
AssignStmt returns *ast.AssignStmt node set.
func (NodeSet) CallExpr__0 ¶ added in v1.3.2
CallExpr returns *ast.CallExpr node set.
func (NodeSet) CallExpr__1 ¶ added in v1.3.2
CallExpr returns *ast.CallExpr node set.
func (NodeSet) CollectOne__0 ¶ added in v1.3.2
CollectOne returns the first node.
func (NodeSet) CollectOne__1 ¶ added in v1.3.2
CollectOne collects one node of a node set. If exactly is true, it returns ErrTooManyNodes when node set is more than one.
func (NodeSet) CompositeLit__0 ¶ added in v1.3.2
CompositeLit returns *ast.CompositeLit node set.
func (NodeSet) CompositeLit__1 ¶ added in v1.3.2
CompositeLit returns *ast.CompositeLit node set.
func (NodeSet) FuncDecl__0 ¶ added in v1.3.2
FuncDecl returns *ast.FuncDecl node set.
func (NodeSet) FuncDecl__1 ¶ added in v1.3.2
FuncDecl returns *ast.FuncDecl node set.
func (NodeSet) GenDecl__0 ¶ added in v1.3.2
GenDecl returns *ast.GenDecl node set.
func (NodeSet) ImportSpec ¶
ImportSpec returns *ast.ImportSpec node set.