-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgo_composite_lit.go
More file actions
47 lines (35 loc) · 918 Bytes
/
go_composite_lit.go
File metadata and controls
47 lines (35 loc) · 918 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
47
package gocoder
import (
"context"
"go/ast"
"go/token"
)
type GoCompositeLit struct {
rootExpr *GoExpr
goChild *GoExpr
astExpr *ast.CompositeLit
}
func newGoCompositeLit(rootExpr *GoExpr, astCompositeLit *ast.CompositeLit) *GoCompositeLit {
g := &GoCompositeLit{
rootExpr: rootExpr,
astExpr: astCompositeLit,
}
g.load()
return g
}
func (p *GoCompositeLit) load() {
p.goChild = newGoExpr(p.rootExpr, p.astExpr.Type)
}
func (p *GoCompositeLit) Type() *GoExpr {
return p.goChild
}
func (p *GoCompositeLit) Inspect(f InspectFunc, ctx context.Context) {
p.goChild.Inspect(f, ctx)
}
func (p *GoCompositeLit) Position() (token.Position, token.Position) {
return p.rootExpr.astFileSet.Position(p.astExpr.Pos()), p.rootExpr.astFileSet.Position(p.astExpr.End())
}
func (p *GoCompositeLit) Print() error {
return ast.Print(p.rootExpr.astFileSet, p.astExpr)
}
func (p *GoCompositeLit) goNode() {}