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

Function getTsWshMethodDataParamsAndExpr

pkg/tsgen/tsgen.go:503–525  ·  view source on GitHub ↗
(methodDecl *wshrpc.WshRpcMethodDecl, tsTypesMap map[reflect.Type]string)

Source from the content-addressed store, hash-verified

501}
502
503func getTsWshMethodDataParamsAndExpr(methodDecl *wshrpc.WshRpcMethodDecl, tsTypesMap map[reflect.Type]string) (string, string) {
504 dataTypes := methodDecl.GetCommandDataTypes()
505 if len(dataTypes) == 0 {
506 return "", "null"
507 }
508 if len(dataTypes) == 1 {
509 cmdDataTsName, _ := TypeToTSType(dataTypes[0], tsTypesMap)
510 return fmt.Sprintf("data: %s", cmdDataTsName), "data"
511 }
512 var methodParamBuilder strings.Builder
513 var argBuilder strings.Builder
514 for idx, dataType := range dataTypes {
515 if idx > 0 {
516 methodParamBuilder.WriteString(", ")
517 argBuilder.WriteString(", ")
518 }
519 argName := fmt.Sprintf("arg%d", idx+1)
520 cmdDataTsName, _ := TypeToTSType(dataType, tsTypesMap)
521 methodParamBuilder.WriteString(fmt.Sprintf("%s: %s", argName, cmdDataTsName))
522 argBuilder.WriteString(argName)
523 }
524 return methodParamBuilder.String(), fmt.Sprintf("{ args: [%s] }", argBuilder.String())
525}
526
527func GenerateWaveObjTypes(tsTypesMap map[reflect.Type]string) {
528 for _, typeUnion := range TypeUnions {

Calls 4

TypeToTSTypeFunction · 0.85
GetCommandDataTypesMethod · 0.80
WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected