Revert "test: [go] add to add property supporT"

This reverts commit db58278e.
上级 db58278e
......@@ -109,27 +109,22 @@ func BuildFieldToProperty(fieldList []*ast.Field) []CodeProperty {
return properties
}
func BuildMethodCall(codeFunc *CodeFunction, item ast.Stmt, fields []CodeField, localVars []CodeProperty, imports []CodeImport, packageName string) ([]CodeProperty, *CodeCall) {
func BuildMethodCall(codeFunc *CodeFunction, item ast.Stmt, fields []CodeField, localVars []CodeProperty, imports []CodeImport, packageName string) ([]CodeProperty, CodeCall) {
var call CodeCall
switch it := item.(type) {
case *ast.ExprStmt:
call = *BuildMethodCallExprStmt(it, codeFunc, fields, imports, packageName, localVars)
BuildMethodCallExprStmt(it, codeFunc, fields, imports, packageName, localVars)
case *ast.DeferStmt:
call = *BuildCallFromExpr(it.Call, codeFunc, fields, imports, packageName, localVars)
call = BuildCallFromExpr(it.Call, codeFunc, fields, imports, packageName, localVars)
codeFunc.FunctionCalls = append(codeFunc.FunctionCalls, call)
case *ast.AssignStmt:
vars := BuildLocalVars(it)
localVars = vars
case *ast.ReturnStmt:
for _, result := range it.Results {
expr, s, s2 := BuildExpr(result)
fmt.Println(expr, s, s2)
}
default:
fmt.Fprintf(output, "methodCall %s\n", reflect.TypeOf(it))
}
return localVars, &call
return localVars, call
}
func BuildLocalVars(it *ast.AssignStmt) []CodeProperty {
......@@ -154,20 +149,17 @@ func BuildLocalVars(it *ast.AssignStmt) []CodeProperty {
return vars
}
func BuildMethodCallExprStmt(it *ast.ExprStmt, codeFunc *CodeFunction, fields []CodeField, imports []CodeImport, currentPackage string, localVars []CodeProperty) *CodeCall {
var call *CodeCall
func BuildMethodCallExprStmt(it *ast.ExprStmt, codeFunc *CodeFunction, fields []CodeField, imports []CodeImport, currentPackage string, localVars []CodeProperty) {
switch expr := it.X.(type) {
case *ast.CallExpr:
call = BuildCallFromExpr(expr, codeFunc, fields, imports, currentPackage, localVars)
codeFunc.FunctionCalls = append(codeFunc.FunctionCalls, *call)
call := BuildCallFromExpr(expr, nil, fields, imports, currentPackage, localVars)
codeFunc.FunctionCalls = append(codeFunc.FunctionCalls, call)
default:
fmt.Fprintf(output, "BuildMethodCallExprStmt: %s\n", reflect.TypeOf(expr))
}
return call
}
func BuildCallFromExpr(expr *ast.CallExpr, codeFunc *CodeFunction, fields []CodeField, imports []CodeImport, currentPackage string, localVars []CodeProperty) *CodeCall {
func BuildCallFromExpr(expr *ast.CallExpr, codeFunc *CodeFunction, fields []CodeField, imports []CodeImport, currentPackage string, localVars []CodeProperty) CodeCall {
_, selector, selName := BuildExpr(expr.Fun.(ast.Expr))
target := ParseTarget(selector, fields, localVars)
packageName := getPackageName(target, imports)
......@@ -188,12 +180,13 @@ func BuildCallFromExpr(expr *ast.CallExpr, codeFunc *CodeFunction, fields []Code
for _, item := range funcLit.Body.List {
_, methodCall := BuildMethodCall(codeFunc, item, fields, localVars, imports, packageName)
fmt.Println(methodCall)
fmt.Println("...", methodCall)
if methodCall.NodeName != "" {
codeFunc.FunctionCalls = append(codeFunc.FunctionCalls, *methodCall)
fmt.Println(methodCall.NodeName)
codeFunc.FunctionCalls = append(codeFunc.FunctionCalls, methodCall)
}
}
}
}
_, value, kind := BuildExpr(arg.(ast.Expr))
property := &CodeProperty{
......@@ -203,8 +196,7 @@ func BuildCallFromExpr(expr *ast.CallExpr, codeFunc *CodeFunction, fields []Code
call.Parameters = append(call.Parameters, *property)
}
return &call
return call
}
func getPackageName(target string, imports []CodeImport) string {
......
......@@ -295,8 +295,6 @@ func BuildExpr(expr ast.Expr) (string, string, string) {
case *ast.FuncLit:
// inner function
fmt.Println(x.Body.List)
case *ast.BinaryExpr:
//fmt.Println(x.Op)
default:
fmt.Fprintf(output, "BuildExpr %s\n", reflect.TypeOf(x))
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册