本文整理汇总了Golang中go/ast.CallExpr.Args方法的典型用法代码示例。如果您正苦于以下问题:Golang CallExpr.Args方法的具体用法?Golang CallExpr.Args怎么用?Golang CallExpr.Args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类go/ast.CallExpr
的用法示例。
在下文中一共展示了CallExpr.Args方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: insertContext
// c may be nil.
func insertContext(f *ast.File, call *ast.CallExpr, c *ast.Ident) {
if c == nil {
// c is unknown, so use a plain "c".
c = ast.NewIdent("c")
}
call.Args = append([]ast.Expr{c}, call.Args...)
}
示例2: insertContext
// ctx may be nil.
func insertContext(f *ast.File, call *ast.CallExpr, ctx *ast.Ident) {
if ctx == nil {
// context is unknown, so use a plain "ctx".
ctx = ast.NewIdent("ctx")
}
call.Args = append([]ast.Expr{ctx}, call.Args...)
}
示例3: changeFuncNameAndAddWriter
func changeFuncNameAndAddWriter(callExpr *ast.CallExpr, newFuncName string) {
// Hacky; we should really create a proper AST. Fine for now, though, and faster, anyway.
callExpr.Fun.(*ast.Ident).Name = newFuncName
// Prepend w to the arg list.
newArgList := make([]ast.Expr, 0, 1+len(callExpr.Args))
newArgList = append(newArgList, writerArg)
newArgList = append(newArgList, callExpr.Args...)
callExpr.Args = newArgList
}
示例4: insertContext
// ctx may be nil.
func insertContext(f *ast.File, call *ast.CallExpr, ctx *ast.Ident) {
if ctx == nil {
// context is unknown, so use a plain "ctx".
ctx = ast.NewIdent("ctx")
} else {
// Create a fresh *ast.Ident so we drop the position information.
ctx = ast.NewIdent(ctx.Name)
}
call.Args = append([]ast.Expr{ctx}, call.Args...)
}
示例5: checkEditME
func (vis *getUsedMethodsVisitor) checkEditME(callExpr *ast.CallExpr, mId *ast.Ident) {
m, ok := vis.identMap.GetSymbol(mId).(*st.FunctionSymbol)
if !ok {
panic("couldn't find method selector in method expression")
}
if id, ok := callExpr.Args[0].(*ast.Ident); ok {
if vis.identMap.GetSymbol(id) == vis.varS {
callExpr.Fun = &ast.SelectorExpr{id, mId}
callExpr.Args = callExpr.Args[1:]
vis.result[m] = true
}
}
}
示例6: wrapCallExprWithTemplatedT
func (rp *rewritePackage) wrapCallExprWithTemplatedT(basicLit *ast.BasicLit, callExpr *ast.CallExpr, argIndex int) {
templatedCallExpr := rp.wrapBasicLitWithTemplatedT(basicLit, callExpr.Args, callExpr, argIndex)
if templatedCallExpr != callExpr {
newArgs := []ast.Expr{}
if argIndex != 0 {
for i, arg := range callExpr.Args {
if i < argIndex {
newArgs = append(newArgs, arg)
}
}
}
callExpr.Args = append(newArgs, templatedCallExpr)
}
}
示例7: finishCapturing
func (v *powerVisitor) finishCapturing(n *ast.CallExpr) {
trace("stop capturing. stack size: ", v.nodeStack.Count(), " poped: ", n)
if selector, ok := n.Fun.(*ast.SelectorExpr); ok {
if selector.Sel.Name == "Ok" {
selector.Sel.Name = "PowerOk"
arg := n.Args[1]
if modified, ok := captExpr(arg); ok {
n.Args[1] = modified
}
n.Args = append(n.Args, &ast.BasicLit{Kind: token.STRING, Value: fmt.Sprintf("\"%s\"", v.original)})
}
}
// modified, _ := ToCode(n)
// log("-r='", v.original, "->", modified, "'")
v.capturingCall = nil
v.original = ""
v.capturing = false
}