Documentation
¶
Index ¶
- func CreateNoopOfStatement(pkg *types.Package, info *types.Info, stmt ast.Stmt) ast.Stmt
- func CreateNoopOfStatements(pkg *types.Package, info *types.Info, stmts []ast.Stmt) ast.Stmt
- func Functions(n ast.Node) []*ast.FuncDecl
- func IdentifiersInStatement(pkg *types.Package, info *types.Info, stmt ast.Stmt) []ast.Expr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNoopOfStatement ¶
CreateNoopOfStatement creates a syntactically safe noop statement out of a given statement.
func CreateNoopOfStatements ¶
CreateNoopOfStatements creates a syntactically safe noop statement out of a given statement.
The replacement is anchored at the position of the first original line of code. Without a position the synthesized tokens (the `_` identifiers and the `=`) default to token.NoPos, which sorts before everything; go/printer then floats a leading comment into the middle of the assignment (e.g. `_, _ =\n// comment\ntotal, x`) and the diff's first hunk line points at the comment rather than the code. Anchoring at the original code position keeps a leading comment above the replacement and makes the diff report the correct original line.
Types ¶
This section is empty.