Documentation ¶
Overview ¶
Package gorefactor provides some basic utilities for you to do code migration on large code base written in golang.
Index ¶
- Variables
- func AddArgToCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr, pos int) (modified bool)
- func AddFieldToFuncDeclParams(df *dst.File, funcName string, field *dst.Field, pos int) (modified bool)
- func AddFieldToFuncLitParams(df *dst.File, scope Scope, field *dst.Field, pos int) (modified bool)
- func AddStmtToFuncBody(df *dst.File, funcName string, stmt dst.Stmt, pos int) (modified bool)
- func AddStmtToFuncBodyAfter(df *dst.File, funcName string, stmt, refStmt dst.Stmt) (modified bool)
- func AddStmtToFuncBodyBefore(df *dst.File, funcName string, stmt, refStmt dst.Stmt) (modified bool)
- func AddStmtToFuncBodyEnd(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)
- func AddStmtToFuncBodyStart(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)
- func AddStmtToFuncLitBody(df *dst.File, scope Scope, stmt dst.Stmt, pos int) (modified bool)
- func DeleteArgFromCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr) (modified bool)
- func DeleteFieldFromFuncDeclParams(df *dst.File, funcName string, field *dst.Field) (modified bool)
- func DeleteSelectorExprFromFuncBody(df *dst.File, funcName string, selectorExpr dst.Expr) (modified bool)
- func DeleteStmtFromFuncBody(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)
- func FprintFile(out io.Writer, df *dst.File) error
- func HasArgInCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr) (ret bool)
- func HasFieldInFuncDeclParams(df *dst.File, funcName string, field *dst.Field) (ret bool)
- func HasStmtInsideFuncBody(df *dst.File, funcName string, stmt dst.Stmt) (ret bool)
- func ParseSrcFile(filename string) (df *dst.File, err error)
- func ParseSrcFileFromBytes(src []byte) (df *dst.File, err error)
- func SetMethodOnReceiver(df *dst.File, scope Scope, receiver, oldMethod, newMethod string) (modified bool)
- type Scope
Constants ¶
This section is empty.
Variables ¶
var EmptyScope = Scope{}
Functions ¶
func AddArgToCallExpr ¶
func AddArgToCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr, pos int) (modified bool)
AddArgToCallExpr adds given arg, to the function call's argument list, in the given position
func AddFieldToFuncDeclParams ¶
func AddFieldToFuncDeclParams(df *dst.File, funcName string, field *dst.Field, pos int) (modified bool)
AddFieldToFuncDeclParams adds given field, to the declaration params of the function, in the given position
func AddFieldToFuncLitParams ¶ added in v0.0.7
AddFieldToFuncLitParams add statement to anonymous function params
func AddStmtToFuncBody ¶
AddStmtToFuncBody adds given statement, to the body of function, in the given position
func AddStmtToFuncBodyAfter ¶ added in v0.0.2
AddStmtToFuncBodyAfter adds given statement, to the function body, after the position of refStmt, if refStmt not found, nothing will happen
func AddStmtToFuncBodyBefore ¶ added in v0.0.2
AddStmtToFuncBodyBefore adds given statement, to the function body, before the position of refStmt. if refStmt not found, nothing will happen
func AddStmtToFuncBodyEnd ¶
AddStmtToFuncBodyEnd adds given statement, to the end of function body
func AddStmtToFuncBodyStart ¶
AddStmtToFuncBodyStart adds given statement, to the start of function body
func AddStmtToFuncLitBody ¶ added in v0.0.7
AddStmtToFuncLitBody add statement to anonymous function body
func DeleteArgFromCallExpr ¶
func DeleteArgFromCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr) (modified bool)
DeleteArgFromCallExpr deletes any arg, in the function call's argument list, that is semantically equal to the given arg.
func DeleteFieldFromFuncDeclParams ¶
DeleteFieldFromFuncDeclParams deletes any field, in the declaration params of the function, that is semantically equal to given field
func DeleteSelectorExprFromFuncBody ¶ added in v0.0.4
func DeleteSelectorExprFromFuncBody(df *dst.File, funcName string, selectorExpr dst.Expr) (modified bool)
DeleteCallExprFromFuncBody deletes any SelectorExpr equal to the given one, inside the body of function.
func DeleteStmtFromFuncBody ¶
DeleteStmtFromFuncBody deletes any statement, inside the body of function, that is semantically equal to the given statement.
func FprintFile ¶
FprintFile writes the *dst.File out to io.Writer
func HasArgInCallExpr ¶
HasArgInCallExpr checks if the arguments of the function call has given arg
func HasFieldInFuncDeclParams ¶
HasFieldInFuncDeclParams checks if the declaration params of the function, contains the given field
func HasStmtInsideFuncBody ¶
HasStmtInsideFuncBody checks if the body of function has given statement
func ParseSrcFile ¶
ParseSrcFile parses the given go src filename, in the form of valid path, into *dst.File
func ParseSrcFileFromBytes ¶
ParseSrcFileFromBytes parses the given go src file, in the form of bytes, into *dst.File
Types ¶
type Scope ¶ added in v0.0.8
type Scope struct { FuncName string // contains filtered or unexported fields }