-
Notifications
You must be signed in to change notification settings - Fork 0
/
structure.go
80 lines (63 loc) · 2.13 KB
/
structure.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package collect
import "go/token"
type Package struct {
Files map[string]*File `json:"-"`
Interfaces map[string]*Object `json:"interfaces"`
Functions map[string]*Func `json:"functions"`
Types map[string]*Object `json:"types"`
FileNames []string `json:"filenames"`
Names []string `json:"names"`
}
func NewPackage() *Package {
return &Package{
Files: map[string]*File{}, FileNames: []string{},
Interfaces: map[string]*Object{},
Functions: map[string]*Func{},
Types: map[string]*Object{},
Names: []string{},
}
}
type File struct {
Interfaces map[string]*Object `json:"interfaces"`
Functions map[string]*Func `json:"functions"`
Types map[string]*Object `json:"types"`
Names []string `json:"names"`
}
func NewFile() *File {
return &File{
Interfaces: map[string]*Object{},
Functions: map[string]*Func{},
Types: map[string]*Object{},
Names: []string{},
}
}
type Func struct {
Name string `json:"name"`
Pos token.Pos `json:"-"`
Recv string `json:"recv,omitempty"`
Params map[string]*Field `json:"params"`
ParamNames []string `json:"paramnames"`
Returns map[string]*Field `json:"returns"`
ReturnNames []string `json:"returnnames"`
Doc string `json:"doc"` // associated documentation; or nil (decl or spec?)
}
type Object struct {
Name string `json:"name"`
Pos token.Pos `json:"-"`
Token token.Token `json:"-"`
Parent *Object `json:"-"`
Fields map[string]*Field `json:"fields,omitempty"`
FieldNames []string `json:"fieldnames,omitempty"`
Methods map[string]*Func `json:"methods,omitempty"`
MethodNames []string `json:"methodnames,omitempty"`
Doc string `json:"doc"` // associated documentation; or nil (decl or spec?)
Comment string `json:"comment"` // line comments; or nil
}
type Field struct {
Name string `json:"name"`
Pos token.Pos `json:"-"`
Embedded bool `json:"embedded"`
Anonymous *Object `json:"annonymous,omitempty"`
Doc string `json:"doc"` // associated documentation; or nil
Comment string `json:"comment"` // line comments; or nil
}