1package gogrep 2 3import ( 4 "go/ast" 5 "go/token" 6) 7 8type nodeSlice interface { 9 at(i int) ast.Node 10 len() int 11 slice(from, to int) nodeSlice 12 ast.Node 13} 14 15type ( 16 exprSlice []ast.Expr 17 stmtSlice []ast.Stmt 18 fieldSlice []*ast.Field 19 identSlice []*ast.Ident 20 specSlice []ast.Spec 21) 22 23func (l exprSlice) len() int { return len(l) } 24func (l exprSlice) at(i int) ast.Node { return l[i] } 25func (l exprSlice) slice(i, j int) nodeSlice { return l[i:j] } 26func (l exprSlice) Pos() token.Pos { return l[0].Pos() } 27func (l exprSlice) End() token.Pos { return l[len(l)-1].End() } 28 29func (l stmtSlice) len() int { return len(l) } 30func (l stmtSlice) at(i int) ast.Node { return l[i] } 31func (l stmtSlice) slice(i, j int) nodeSlice { return l[i:j] } 32func (l stmtSlice) Pos() token.Pos { return l[0].Pos() } 33func (l stmtSlice) End() token.Pos { return l[len(l)-1].End() } 34 35func (l fieldSlice) len() int { return len(l) } 36func (l fieldSlice) at(i int) ast.Node { return l[i] } 37func (l fieldSlice) slice(i, j int) nodeSlice { return l[i:j] } 38func (l fieldSlice) Pos() token.Pos { return l[0].Pos() } 39func (l fieldSlice) End() token.Pos { return l[len(l)-1].End() } 40 41func (l identSlice) len() int { return len(l) } 42func (l identSlice) at(i int) ast.Node { return l[i] } 43func (l identSlice) slice(i, j int) nodeSlice { return l[i:j] } 44func (l identSlice) Pos() token.Pos { return l[0].Pos() } 45func (l identSlice) End() token.Pos { return l[len(l)-1].End() } 46 47func (l specSlice) len() int { return len(l) } 48func (l specSlice) at(i int) ast.Node { return l[i] } 49func (l specSlice) slice(i, j int) nodeSlice { return l[i:j] } 50func (l specSlice) Pos() token.Pos { return l[0].Pos() } 51func (l specSlice) End() token.Pos { return l[len(l)-1].End() } 52