aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2023-05-16Add note about getting function ScopeTeddy Wing
2023-05-16Add note about (*ast.CallExpr).ArgsTeddy Wing
Discovered this existed.
2023-05-16Trying to get `types.Scope` of function literalTeddy Wing
Not working, as `funcObj` is nil.
2023-05-16Print origin and scope information of closure variablesTeddy Wing
Debugging and ideas for getting variables defined in this closure's scope.
2023-05-16Use `pass.TypesInfo.Defs[ident]` to differentiate DEFINE/ASSIGNTeddy Wing
Got this idea from a question by zhizhixiong (https://stackoverflow.com/users/12073516/zhizhixiong) on Stack Overflow: https://stackoverflow.com/questions/66544145/how-to-find-the-declaration-of-an-ident-using-go-analysis This seems to correctly print defines and assigns. It doesn't print the `decl` variable though.
2023-05-15`(*AssignStmt).Tok` always appears to be token.DEFINETeddy Wing
2023-05-15assignmentsInFunc: Try checking `(*AssignStmt).Tok`Teddy Wing
This field could maybe tell us whether it was a `:=` assignment (token.DEFINE) or `=` (token.ASSIGN), but it seems like it's always `token.DEFINE`.
2023-05-15Try getting `GenDecl`s in closureTeddy Wing
Turns out this only gets declarations like: var decl string but not: decl := "a" Is there a way to get the above one too?
2023-05-15Add test for reference argumentsTeddy Wing
These should be reported as well, because they're shared references even though they're passed as arguments. This currently reports the variable name as "aStruct", will need to look into how to correct that.
2023-05-15Add a new test for struct methodsTeddy Wing
2023-05-15Idea for getting variable declarations instead of assignmentsTeddy Wing
2023-05-15Get assignments in closureTeddy Wing
Turns out this isn't what we want, as assignments means assignments. I was actually thinking of declarations.
2023-05-15Idea for building a list of variable assignmentsTeddy Wing
2023-05-15Ignore variables from the closure's formal argumentsTeddy Wing
Don't report variables that were passed as arguments to the closure.
2023-05-15Find out how to get closure argumentsTeddy Wing
2023-05-15Ideas for finding out whether a variable is a captured referenceTeddy Wing
2023-05-15Try to limit identifier enumeration to variablesTeddy Wing
This does ignore "strings" and "Repeat" in the "simple.go" test file.
2023-05-15testdata/simple.go: Add package and function callTeddy Wing
Need to refine our identifier filtering.
2023-05-15testdata/simple.go: Add a local variable in closureTeddy Wing
We want to ignore local variables.
2023-05-15testdata/simple.go: Find out what happens when var is reusedTeddy Wing
Second usage of captured reference is reported as expected. That seems correct for our needs.
2023-05-15Find variables in `go func` closuresTeddy Wing
Inspect function literals run by `go` statements, and find all variables in those function literals.
2023-05-14Find `go` statements using Go analyzerTeddy Wing
Build a basic Go analyser that finds `go` statements. Currently testing this with: $ go run ./cmd/gocapturedrefrace ./testdata/ Using the following tutorials as a guide: * https://arslan.io/2019/06/13/using-go-analysis-to-write-a-custom-linter/ * https://scribe.rip/codex/writing-custom-linter-in-go-54ef6f8080
2023-05-13Add Idea.txtTeddy Wing