MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / GenMethod_Call

Function GenMethod_Call

pkg/gogen/gogen.go:76–95  ·  view source on GitHub ↗
(buf *strings.Builder, methodDecl *wshrpc.WshRpcMethodDecl)

Source from the content-addressed store, hash-verified

74}
75
76func GenMethod_Call(buf *strings.Builder, methodDecl *wshrpc.WshRpcMethodDecl) {
77 fmt.Fprintf(buf, "// command %q, wshserver.%s\n", methodDecl.Command, methodDecl.MethodName)
78 dataType, dataVarName := getWshMethodDataParamsAndExpr(methodDecl)
79 returnType := "error"
80 respName := "_"
81 tParamVal := "any"
82 if methodDecl.DefaultResponseDataType != nil {
83 returnType = "(" + methodDecl.DefaultResponseDataType.String() + ", error)"
84 respName = "resp"
85 tParamVal = methodDecl.DefaultResponseDataType.String()
86 }
87 fmt.Fprintf(buf, "func %s(w *wshutil.WshRpc%s, opts *wshrpc.RpcOpts) %s {\n", methodDecl.MethodName, dataType, returnType)
88 fmt.Fprintf(buf, "\t%s, err := sendRpcRequestCallHelper[%s](w, %q, %s, opts)\n", respName, tParamVal, methodDecl.Command, dataVarName)
89 if methodDecl.DefaultResponseDataType != nil {
90 fmt.Fprintf(buf, "\treturn resp, err\n")
91 } else {
92 fmt.Fprintf(buf, "\treturn err\n")
93 }
94 fmt.Fprintf(buf, "}\n\n")
95}
96
97func GenMethod_ResponseStream(buf *strings.Builder, methodDecl *wshrpc.WshRpcMethodDecl) {
98 fmt.Fprintf(buf, "// command %q, wshserver.%s\n", methodDecl.Command, methodDecl.MethodName)

Callers 2

GenerateWshClientFunction · 0.92

Calls 2

StringMethod · 0.45

Tested by 1