mirror of
https://github.com/mgechev/revive.git
synced 2025-03-03 14:52:54 +02:00
25 lines
437 B
Go
25 lines
437 B
Go
package ifelse
|
|
|
|
import "go/ast"
|
|
|
|
// Target decides what line/column should be indicated by the rule in question.
|
|
type Target int
|
|
|
|
const (
|
|
// TargetIf means the text refers to the "if"
|
|
TargetIf Target = iota
|
|
|
|
// TargetElse means the text refers to the "else"
|
|
TargetElse
|
|
)
|
|
|
|
func (t Target) node(ifStmt *ast.IfStmt) ast.Node {
|
|
switch t {
|
|
case TargetIf:
|
|
return ifStmt
|
|
case TargetElse:
|
|
return ifStmt.Else
|
|
}
|
|
panic("bad target")
|
|
}
|