Documentation ¶
Index ¶
- func GetNameList(ids []*ast.Ident) (names []string)
- func PrintNodes(objs ...interface{})
- func TrimComment(c string) string
- type CodeParser
- type CodeSource
- func (cs *CodeSource) AddCode(code []byte) error
- func (cs *CodeSource) AddImport(path, alias string) bool
- func (cs *CodeSource) AddReplace(first, last ast.Node, code string)
- func (cs *CodeSource) AddStringCode(code string) error
- func (cs *CodeSource) AltSource() ([]byte, bool)
- func (cs *CodeSource) DelImport(path, alias string) bool
- func (cs *CodeSource) GetComment(c *ast.CommentGroup, trim bool) string
- func (cs *CodeSource) GetContent() ([]byte, error)
- func (cs *CodeSource) GetNodeCode(node ast.Node) string
- func (cs *CodeSource) GetPackage() string
- func (cs *CodeSource) GetPackageOffset() int
- func (cs *CodeSource) SetPackage(name string) (err error)
- func (cs *CodeSource) SetSource(source []byte) (err error)
- func (cs *CodeSource) WriteSource(filename string) error
- func (cs *CodeSource) WriteTo(filename string) error
- type DeclNode
- type FieldNode
- type PosAlt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNameList ¶ added in v0.6.2
func PrintNodes ¶
func PrintNodes(objs ...interface{})
func TrimComment ¶
Types ¶
type CodeParser ¶
type CodeParser struct { DeclNodes []*DeclNode DeclIndexes map[string][]int *CodeSource }
func NewCodeParser ¶
func NewCodeParser() *CodeParser
func NewFileParser ¶
func NewFileParser(filename string) (cp *CodeParser, err error)
func NewSourceParser ¶
func NewSourceParser(source []byte) (cp *CodeParser, err error)
func (*CodeParser) AllDeclNode ¶
func (cp *CodeParser) AllDeclNode(kind string) []*DeclNode
func (*CodeParser) GetDeclNode ¶
func (cp *CodeParser) GetDeclNode(kind string, offset int) *DeclNode
func (*CodeParser) ParseDecls ¶
func (cp *CodeParser) ParseDecls(kind string, limit int) bool
type CodeSource ¶
type CodeSource struct { Fileast *ast.File Fileset *token.FileSet Source []byte Alternates []PosAlt // Source 只能替换一次,然后必须重新解析 Fileast *printer.Config }
func NewCodeSource ¶
func NewCodeSource() *CodeSource
func ResetImports ¶ added in v0.6.4
func ResetImports(cs *CodeSource, imports map[string]string) (*CodeSource, error)
func WithImports ¶ added in v0.6.4
func (*CodeSource) AddCode ¶
func (cs *CodeSource) AddCode(code []byte) error
func (*CodeSource) AddImport ¶
func (cs *CodeSource) AddImport(path, alias string) bool
func (*CodeSource) AddReplace ¶ added in v0.6.3
func (cs *CodeSource) AddReplace(first, last ast.Node, code string)
func (*CodeSource) AddStringCode ¶
func (cs *CodeSource) AddStringCode(code string) error
func (*CodeSource) AltSource ¶ added in v0.6.3
func (cs *CodeSource) AltSource() ([]byte, bool)
func (*CodeSource) DelImport ¶
func (cs *CodeSource) DelImport(path, alias string) bool
func (*CodeSource) GetComment ¶
func (cs *CodeSource) GetComment(c *ast.CommentGroup, trim bool) string
func (*CodeSource) GetContent ¶
func (cs *CodeSource) GetContent() ([]byte, error)
func (*CodeSource) GetNodeCode ¶
func (cs *CodeSource) GetNodeCode(node ast.Node) string
func (*CodeSource) GetPackage ¶
func (cs *CodeSource) GetPackage() string
func (*CodeSource) GetPackageOffset ¶ added in v0.6.4
func (cs *CodeSource) GetPackageOffset() int
func (*CodeSource) SetPackage ¶
func (cs *CodeSource) SetPackage(name string) (err error)
func (*CodeSource) SetSource ¶
func (cs *CodeSource) SetSource(source []byte) (err error)
func (*CodeSource) WriteSource ¶ added in v0.6.3
func (cs *CodeSource) WriteSource(filename string) error
func (*CodeSource) WriteTo ¶
func (cs *CodeSource) WriteTo(filename string) error
type DeclNode ¶
type DeclNode struct { Token token.Token Kinds []string Names []string Fields []*FieldNode Comment *ast.CommentGroup Offset int ast.Decl }
func NewDeclNode ¶
Click to show internal directories.
Click to hide internal directories.