2021-11-14 20:01:54 +00:00
|
|
|
package gogrep
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go/ast"
|
|
|
|
"go/token"
|
|
|
|
)
|
|
|
|
|
2021-11-16 20:07:53 +00:00
|
|
|
type NodeSlice interface {
|
|
|
|
At(i int) ast.Node
|
|
|
|
Len() int
|
|
|
|
slice(from, to int) NodeSlice
|
2021-11-14 20:01:54 +00:00
|
|
|
ast.Node
|
|
|
|
}
|
|
|
|
|
|
|
|
type (
|
2021-11-16 20:07:53 +00:00
|
|
|
ExprSlice []ast.Expr
|
2021-11-14 20:01:54 +00:00
|
|
|
stmtSlice []ast.Stmt
|
|
|
|
fieldSlice []*ast.Field
|
|
|
|
identSlice []*ast.Ident
|
|
|
|
specSlice []ast.Spec
|
2021-11-16 20:07:53 +00:00
|
|
|
declSlice []ast.Decl
|
2021-11-14 20:01:54 +00:00
|
|
|
)
|
|
|
|
|
2021-11-16 20:07:53 +00:00
|
|
|
func (l ExprSlice) Len() int { return len(l) }
|
|
|
|
func (l ExprSlice) At(i int) ast.Node { return l[i] }
|
|
|
|
func (l ExprSlice) slice(i, j int) NodeSlice { return l[i:j] }
|
|
|
|
func (l ExprSlice) Pos() token.Pos { return l[0].Pos() }
|
|
|
|
func (l ExprSlice) End() token.Pos { return l[len(l)-1].End() }
|
2021-11-14 20:01:54 +00:00
|
|
|
|
2021-11-16 20:07:53 +00:00
|
|
|
func (l stmtSlice) Len() int { return len(l) }
|
|
|
|
func (l stmtSlice) At(i int) ast.Node { return l[i] }
|
|
|
|
func (l stmtSlice) slice(i, j int) NodeSlice { return l[i:j] }
|
2021-11-14 20:01:54 +00:00
|
|
|
func (l stmtSlice) Pos() token.Pos { return l[0].Pos() }
|
|
|
|
func (l stmtSlice) End() token.Pos { return l[len(l)-1].End() }
|
|
|
|
|
2021-11-16 20:07:53 +00:00
|
|
|
func (l fieldSlice) Len() int { return len(l) }
|
|
|
|
func (l fieldSlice) At(i int) ast.Node { return l[i] }
|
|
|
|
func (l fieldSlice) slice(i, j int) NodeSlice { return l[i:j] }
|
2021-11-14 20:01:54 +00:00
|
|
|
func (l fieldSlice) Pos() token.Pos { return l[0].Pos() }
|
|
|
|
func (l fieldSlice) End() token.Pos { return l[len(l)-1].End() }
|
|
|
|
|
2021-11-16 20:07:53 +00:00
|
|
|
func (l identSlice) Len() int { return len(l) }
|
|
|
|
func (l identSlice) At(i int) ast.Node { return l[i] }
|
|
|
|
func (l identSlice) slice(i, j int) NodeSlice { return l[i:j] }
|
2021-11-14 20:01:54 +00:00
|
|
|
func (l identSlice) Pos() token.Pos { return l[0].Pos() }
|
|
|
|
func (l identSlice) End() token.Pos { return l[len(l)-1].End() }
|
|
|
|
|
2021-11-16 20:07:53 +00:00
|
|
|
func (l specSlice) Len() int { return len(l) }
|
|
|
|
func (l specSlice) At(i int) ast.Node { return l[i] }
|
|
|
|
func (l specSlice) slice(i, j int) NodeSlice { return l[i:j] }
|
2021-11-14 20:01:54 +00:00
|
|
|
func (l specSlice) Pos() token.Pos { return l[0].Pos() }
|
|
|
|
func (l specSlice) End() token.Pos { return l[len(l)-1].End() }
|
2021-11-16 20:07:53 +00:00
|
|
|
|
|
|
|
func (l declSlice) Len() int { return len(l) }
|
|
|
|
func (l declSlice) At(i int) ast.Node { return l[i] }
|
|
|
|
func (l declSlice) slice(i, j int) NodeSlice { return l[i:j] }
|
|
|
|
func (l declSlice) Pos() token.Pos { return l[0].Pos() }
|
|
|
|
func (l declSlice) End() token.Pos { return l[len(l)-1].End() }
|