forked from gogap/gocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgo_array.go
More file actions
46 lines (35 loc) · 852 Bytes
/
go_array.go
File metadata and controls
46 lines (35 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package gocoder
import (
"context"
"go/ast"
"go/token"
)
type GoArray struct {
rootExpr *GoExpr
astExpr *ast.ArrayType
astEle *GoExpr
}
func newGoArray(rootExpr *GoExpr, astExpr *ast.ArrayType) *GoArray {
g := &GoArray{
rootExpr: rootExpr,
astExpr: astExpr,
astEle: newGoExpr(rootExpr, astExpr.Elt),
}
return g
}
func (p *GoArray) Name() string {
return astTypeToStringType(p.astExpr)
}
func (p *GoArray) Inspect(f InspectFunc, ctx context.Context) {
p.astEle.Inspect(f, ctx)
}
func (p *GoArray) Ele() *GoExpr {
return p.astEle
}
func (p *GoArray) goNode() {}
func (p *GoArray) Position() (token.Position, token.Position) {
return p.rootExpr.astFileSet.Position(p.astExpr.Pos()), p.rootExpr.astFileSet.Position(p.astExpr.End())
}
func (p *GoArray) Print() error {
return ast.Print(p.rootExpr.astFileSet, p.astExpr)
}