-
Notifications
You must be signed in to change notification settings - Fork 14
/
reg_generic.go
85 lines (64 loc) · 1.42 KB
/
reg_generic.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
81
82
83
84
85
package goql
import (
"github.com/fzerorubigd/goql/astdata"
)
type filer interface {
File() *astdata.File
}
type packager interface {
Package() *astdata.Package
}
type namer interface {
Name() string
}
type docer interface {
Docs() astdata.Docs
}
type definithioner interface {
Definition() astdata.Definition
}
type genericFileName struct {
}
func (genericFileName) Value(in interface{}) String {
f := in.(filer)
return String{String: f.File().FileName()}
}
type genericPackageName struct {
}
func (genericPackageName) Value(in interface{}) String {
p := in.(packager)
return String{String: p.Package().Name()}
}
type genericPackagePath struct {
}
func (genericPackagePath) Value(in interface{}) String {
p := in.(packager)
return String{String: p.Package().Path()}
}
type genericName struct {
}
func (genericName) Value(in interface{}) String {
p := in.(namer)
return String{String: p.Name()}
}
type genericIsExported struct {
}
func (genericIsExported) Value(in interface{}) Bool {
p := in.(namer).Name()
t := p[0] <= 'Z' && p[0] >= 'A'
return Bool{Bool: t}
}
type genericDoc struct{}
func (genericDoc) Value(in interface{}) String {
p := in.(docer).Docs()
if len(p) == 0 {
return String{Null: true}
}
return String{String: p.String()}
}
type genericDefinition struct {
}
func (genericDefinition) Value(in interface{}) Definition {
def := in.(definithioner).Definition()
return Definition{Definition: def}
}