mirror of
https://github.com/Crocmagnon/fatcontext.git
synced 2024-11-22 07:58:05 +01:00
fix: don't touch AST
This commit is contained in:
parent
75b2beb848
commit
e294cd822f
1 changed files with 8 additions and 4 deletions
|
@ -3,7 +3,6 @@ package analyzer
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/printer"
|
"go/printer"
|
||||||
"go/token"
|
"go/token"
|
||||||
|
@ -54,15 +53,20 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
assignStmt.Tok = token.DEFINE
|
suggestedStmt := ast.AssignStmt{
|
||||||
suggested := render(pass.Fset, assignStmt)
|
Lhs: assignStmt.Lhs,
|
||||||
|
TokPos: assignStmt.TokPos,
|
||||||
|
Tok: token.DEFINE,
|
||||||
|
Rhs: assignStmt.Rhs,
|
||||||
|
}
|
||||||
|
suggested := render(pass.Fset, &suggestedStmt)
|
||||||
|
|
||||||
pass.Report(analysis.Diagnostic{
|
pass.Report(analysis.Diagnostic{
|
||||||
Pos: assignStmt.Pos(),
|
Pos: assignStmt.Pos(),
|
||||||
Message: "context not shadowed in loop",
|
Message: "context not shadowed in loop",
|
||||||
SuggestedFixes: []analysis.SuggestedFix{
|
SuggestedFixes: []analysis.SuggestedFix{
|
||||||
{
|
{
|
||||||
Message: fmt.Sprintf("replace `=` with `:=`"),
|
Message: "replace `=` with `:=`",
|
||||||
TextEdits: []analysis.TextEdit{
|
TextEdits: []analysis.TextEdit{
|
||||||
{
|
{
|
||||||
Pos: assignStmt.Pos(),
|
Pos: assignStmt.Pos(),
|
||||||
|
|
Loading…
Reference in a new issue