aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-05-16 21:25:14 +0200
committerTeddy Wing2023-05-16 21:25:14 +0200
commit79f8de910e6ec7fbb123945385789f19091e0a07 (patch)
treed312ac99da657e6879e18a461d7f1d3801c2b8d6
parentad4b4956a5ac8d08b271417687e354e5c66491a8 (diff)
downloadgocapturedrefrace-79f8de910e6ec7fbb123945385789f19091e0a07.tar.bz2
run: Clean up old code
Remove old unused in-progress code.
-rw-r--r--gocapturedrefrace.go49
1 files changed, 1 insertions, 48 deletions
diff --git a/gocapturedrefrace.go b/gocapturedrefrace.go
index c3d5d82..6d560a1 100644
--- a/gocapturedrefrace.go
+++ b/gocapturedrefrace.go
@@ -1,10 +1,8 @@
package gocapturedrefrace
import (
- "bytes"
"fmt"
"go/ast"
- "go/printer"
"go/token"
"go/types"
@@ -27,54 +25,13 @@ func run(pass *analysis.Pass) (interface{}, error) {
return true
}
- var printedNode bytes.Buffer
- err := printer.Fprint(&printedNode, pass.Fset, goStmt)
- if err != nil {
- panic(err)
- }
-
- fmt.Printf("%#v\n", goStmt)
- fmt.Printf("closure arguments: %#v\n", goStmt.Call.Args)
-
- // for _, arg := range goStmt.Call.Args {
- // argIdent, ok := arg.(*ast.Ident)
- // if !ok {
- // return true
- // }
- //
- // fmt.Printf("argIdent: %s: %#v\n", argIdent.Name, argIdent.Obj)
- // // Doesn't include `(s *aStruct)` which is a `*ast.UnaryExpr`, not a `*ast.Ident`.
- // }
-
- // TODO: How to get types.Func or {ast,types}.Scope of function literal?
- funcIdent, ok := goStmt.Call.Fun.(*ast.Ident)
- funcObj := pass.TypesInfo.ObjectOf(funcIdent)
- if funcObj != nil {
- theFunc, ok := funcObj.(*types.Func)
- if ok {
- fmt.Printf("func scope: %#v\n", theFunc.Scope())
- } else {
- fmt.Println("func scope: error")
- }
- } else {
- fmt.Println("funcObj: error")
- }
-
- // TODO: Get func literal of go statement
- // TODO: Get variables in func literal
funcLit, ok := goStmt.Call.Fun.(*ast.FuncLit)
if !ok {
return true
}
- fmt.Printf("funcLit params: %#v\n", funcLit.Type.Params.List)
for _, arg := range funcLit.Type.Params.List {
- fmt.Printf(
- "funcLit param: %s ; type: %#v\n",
- arg.Names[0].Name,
- arg.Type,
- )
-
+ // TODO: Explain
_, ok := arg.Type.(*ast.StarExpr)
if !ok {
continue
@@ -87,11 +44,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
)
}
- // scope := pass.TypesInfo.Scopes[funcLit]
- // scope := pass.TypesInfo.Scopes[goStmt]
- // scope := pass.TypesInfo.Scopes[funcLit.Body]
funcScope := pass.TypesInfo.Scopes[funcLit.Type]
- fmt.Println("scope:", funcScope)
checkClosure(pass, funcLit, funcScope)