-
Notifications
You must be signed in to change notification settings - Fork 14
/
map.go
45 lines (37 loc) · 783 Bytes
/
map.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
package astdata
import (
"fmt"
"go/ast"
)
// MapType is the map in the go code
type MapType struct {
embededData
key Definition
value Definition
}
func (m *MapType) String() string {
return fmt.Sprintf("map[%s]%s", m.key.String(), m.value.String())
}
// Key type definition
func (m *MapType) Key() Definition {
return m.key
}
// Val is the definition of the value type
func (m *MapType) Val() Definition {
return m.value
}
// Compare try to compare this to def
func (m *MapType) Compare(def Definition) bool {
return m.String() == def.String()
}
func getMap(p *Package, f *File, t *ast.MapType) Definition {
return &MapType{
embededData: embededData{
pkg: p,
fl: f,
node: t,
},
key: newType(p, f, t.Key),
value: newType(p, f, t.Value),
}
}