-
Notifications
You must be signed in to change notification settings - Fork 8
/
types_origin.go
58 lines (50 loc) · 954 Bytes
/
types_origin.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
package gotype
import (
"go/ast"
)
func newTypeOrigin(v Type, ori ast.Node, info *info, doc, comment *ast.CommentGroup) Type {
return &typeOrigin{
Type: v,
info: info,
ori: ori,
doc: doc,
comment: comment,
}
}
type typeOrigin struct {
Type
ori ast.Node
info *info
goroot bool
doc *ast.CommentGroup
comment *ast.CommentGroup
pkgPath string
}
func (t *typeOrigin) Origin() ast.Node {
return t.ori
}
func (t *typeOrigin) PkgPath() string {
if t.pkgPath != "" {
return t.pkgPath
}
t.pkgPath = t.Type.PkgPath()
if t.pkgPath == "" {
t.pkgPath = t.info.PkgPath
}
return t.pkgPath
}
func (t *typeOrigin) IsGoroot() bool {
return t.info.Goroot || t.Type.IsGoroot()
}
func (t *typeOrigin) Doc() *ast.CommentGroup {
if t.doc != nil {
return t.doc
}
return t.Type.Doc()
}
func (t *typeOrigin) Comment() *ast.CommentGroup {
if t.comment != nil {
return t.comment
}
return t.Type.Comment()
}