rst

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 AddEmptyLineIntoFuncBody added in v1.1.6

func AddEmptyLineIntoFuncBody(df *dst.File, funcName string) (modified bool)

AddEmptyLineIntoFuncBody add an empty line, inside the body of function,

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

func AddFieldToFuncLitParams(df *dst.File, scope Scope, field *dst.Field, pos int) (modified bool)

AddFieldToFuncLitParams add statement to anonymous function params

func AddStmtToFuncBody

func AddStmtToFuncBody(df *dst.File, funcName string, stmt dst.Stmt, pos int) (modified bool)

AddStmtToFuncBody adds given statement, to the body of function, in the given position

func AddStmtToFuncBodyAfter

func AddStmtToFuncBodyAfter(df *dst.File, funcName string, stmt, refStmt dst.Stmt) (modified bool)

AddStmtToFuncBodyAfter adds given statement, to the function body, after the position of refStmt, if refStmt not found, nothing will happen

func AddStmtToFuncBodyBefore

func AddStmtToFuncBodyBefore(df *dst.File, funcName string, stmt, refStmt dst.Stmt) (modified bool)

AddStmtToFuncBodyBefore adds given statement, to the function body, before the position of refStmt. if refStmt not found, nothing will happen

func AddStmtToFuncBodyEnd

func AddStmtToFuncBodyEnd(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)

AddStmtToFuncBodyEnd adds given statement, to the end of function body

func AddStmtToFuncBodyEndWithRecv

func AddStmtToFuncBodyEndWithRecv(df *dst.File, recvName, funcName string, stmt dst.Stmt) (modified bool)

AddStmtToFuncBodyEndWithRecv adds given statement, to the end of function body

func AddStmtToFuncBodyStart

func AddStmtToFuncBodyStart(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)

AddStmtToFuncBodyStart adds given statement, to the start of function body

func AddStmtToFuncBodyStartWithRecv

func AddStmtToFuncBodyStartWithRecv(df *dst.File, recvName, funcName string, stmt dst.Stmt) (modified bool)

AddStmtToFuncBodyStartWithRecv adds given statement, to the start of function body

func AddStmtToFuncBodyWithRecv

func AddStmtToFuncBodyWithRecv(df *dst.File, recvName string, funcName string, stmt dst.Stmt, pos int) (modified bool)

AddStmtToFuncBodyWithRecv adds given statement, to the body of function, in the given position

func AddStmtToFuncLitBody

func AddStmtToFuncLitBody(df *dst.File, scope Scope, stmt dst.Stmt, pos int) (modified bool)

AddStmtToFuncLitBody add statement to anonymous function body

func AddVarIntoBlockGenDecl added in v1.1.3

func AddVarIntoBlockGenDecl(df *dst.File, varIndex int64, spec *dst.ValueSpec) (ret bool)

func DeleteAllStmtFromFuncBody added in v1.1.6

func DeleteAllStmtFromFuncBody(df *dst.File, funcName string) (modified bool)

DeleteAllStmtFromFuncBody deletes any statement, inside the body of function, that is semantically equal to the given statement.

func DeleteAllStmtFromFuncBodyWithRecv added in v1.0.4

func DeleteAllStmtFromFuncBodyWithRecv(df *dst.File, recvName, funcName string) (modified bool)

DeleteAllStmtFromFuncBodyWithRecv deletes any statement, inside the body of function, that is semantically equal to the given statement.

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 DeleteArgToCallExpr added in v1.0.5

func DeleteArgToCallExpr(df *dst.File, scope Scope, funcName string, pos int) (modified bool)

DeleteArgToCallExpr delete arg, to the function call's argument list, in the given position

func DeleteFieldFromFuncDeclParams

func DeleteFieldFromFuncDeclParams(df *dst.File, funcName string, field *dst.Field) (modified bool)

DeleteFieldFromFuncDeclParams deletes any field, in the declaration params of the function, that is semantically equal to given field

func DeleteFuncFromFile added in v1.1.6

func DeleteFuncFromFile(df *dst.File, funcName string) (modified bool)

DeleteFuncFromFile deletes any func, inside the body of file, that is DeleteFuncFromFile.

func DeleteSelectorExprFromFuncBody

func DeleteSelectorExprFromFuncBody(df *dst.File, funcName string, selectorExpr dst.Expr) (modified bool)

DeleteSelectorExprFromFuncBody deletes any SelectorExpr equal to the given one, inside the body of function.

func DeleteStmtFromFuncBody

func DeleteStmtFromFuncBody(df *dst.File, funcName string, stmt dst.Stmt) (modified bool)

DeleteStmtFromFuncBody deletes any statement, inside the body of function, that is semantically equal to the given statement.

func FprintFile

func FprintFile(out io.Writer, df *dst.File, resolver guess.RestorerResolver, alias []PkgAlias) error

FprintFile writes the *dst.File out to io.Writer

func GetAnnotLineInFuncDeclComment

func GetAnnotLineInFuncDeclComment(df *dst.File, funcName, sign, annot string) (ret string)

func GetFuncDeclListWithPrefixSuffixInFile added in v1.1.3

func GetFuncDeclListWithPrefixSuffixInFile(df *dst.File, prefix, suffix string) (ret []string)

func HasArgInCallExpr

func HasArgInCallExpr(df *dst.File, scope Scope, funcName string, arg dst.Expr) (ret bool)

HasArgInCallExpr checks if the arguments of the function call has given arg

func HasFieldInFuncDeclParams

func HasFieldInFuncDeclParams(df *dst.File, funcName string, field *dst.Field) (ret bool)

HasFieldInFuncDeclParams checks if the declaration params of the function, contains the given field

func HasFuncDeclInFile

func HasFuncDeclInFile(df *dst.File, decl dst.FuncDecl) (ret bool)

func HasFuncDeclWithRecvInFile

func HasFuncDeclWithRecvInFile(df *dst.File, decl dst.FuncDecl, recvName string) (ret bool)

func HasSignInFuncComment

func HasSignInFuncComment(df *dst.File, funcName, sign string) (ret bool)

func HasStmtInsideFuncBody

func HasStmtInsideFuncBody(df *dst.File, funcName string, stmt dst.Stmt) (ret bool)

HasStmtInsideFuncBody checks if the body of function has given statement

func HasStmtInsideFuncBodyWithRecv

func HasStmtInsideFuncBodyWithRecv(df *dst.File, recvName, funcName string, stmt dst.Stmt) (ret bool)

HasStmtInsideFuncBodyWithRecv checks if the body of function has given statement

func HasStructDeclInFile

func HasStructDeclInFile(df *dst.File, structName string) (ret bool)

func HasVarInBlockGenDecl added in v1.1.3

func HasVarInBlockGenDecl(df *dst.File, varIndex int64, spec *dst.ValueSpec) (ret bool)

func ParseSrcFile

func ParseSrcFile(filename string, resolver guess.RestorerResolver) (df *dst.File, err error)

ParseSrcFile parses the given go src filename, in the form of valid path, into *dst.File

func ParseSrcFileFromBytes

func ParseSrcFileFromBytes(src []byte, resolver guess.RestorerResolver) (df *dst.File, err error)

ParseSrcFileFromBytes parses the given go src file, in the form of bytes, into *dst.File

func PrintToBuf

func PrintToBuf(df *dst.File, resolver guess.RestorerResolver, alias []PkgAlias) *bytes.Buffer

func ReplaceFuncNameAndArgWithIndexInCallExpr added in v1.1.3

func ReplaceFuncNameAndArgWithIndexInCallExpr(df *dst.File, scope Scope, funcName string, sign dst.Expr, newFuncName string, pos int, arg dst.Expr) (ret bool)

ReplaceFuncNameAndArgWithIndexInCallExpr replace arguments of the function call has given sign arg, then replace arg

func SetMethodOnReceiver

func SetMethodOnReceiver(df *dst.File, scope Scope, receiver, oldMethod, newMethod string) (modified bool)

func TrimAnnot

func TrimAnnot(s string) string

Types

type PkgAlias

type PkgAlias struct {
	Pkg   string
	Alias string
}

type Scope

type Scope struct {
	FuncName string
	// contains filtered or unexported fields
}

func (Scope) IsInScope

func (s Scope) IsInScope() bool

func (*Scope) TryEnterScope

func (s *Scope) TryEnterScope(node dst.Node) (ok bool)

func (*Scope) TryLeaveScope

func (s *Scope) TryLeaveScope(node dst.Node) (ok bool)

type StructDecs

type StructDecs struct {
	Name string
	Decs dst.Decorations
}

func GetStructDecsInStructComment

func GetStructDecsInStructComment(df *dst.File, sign string) (ret []StructDecs)

Jump to

Keyboard shortcuts

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