/
map.go
42 lines (36 loc) · 1.13 KB
/
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
package decorator
import (
"go/ast"
"github.com/dave/dst"
)
func newMap() Map {
return Map{
Ast: AstMap{
Nodes: map[dst.Node]ast.Node{},
Scopes: map[*dst.Scope]*ast.Scope{},
Objects: map[*dst.Object]*ast.Object{},
},
Dst: DstMap{
Nodes: map[ast.Node]dst.Node{},
Scopes: map[*ast.Scope]*dst.Scope{},
Objects: map[*ast.Object]*dst.Object{},
},
}
}
// Map holds a record of the mapping between ast and dst nodes, objects and scopes.
type Map struct {
Ast AstMap
Dst DstMap
}
// AstMap holds a record of the mapping from dst to ast nodes, objects and scopes.
type AstMap struct {
Nodes map[dst.Node]ast.Node // Mapping from dst to ast Nodes
Objects map[*dst.Object]*ast.Object // Mapping from dst to ast Objects
Scopes map[*dst.Scope]*ast.Scope // Mapping from dst to ast Scopes
}
// DstMap holds a record of the mapping from ast to dst nodes, objects and scopes.
type DstMap struct {
Nodes map[ast.Node]dst.Node // Mapping from ast to dst Nodes
Objects map[*ast.Object]*dst.Object // Mapping from ast to dst Objects
Scopes map[*ast.Scope]*dst.Scope // Mapping from ast to dst Scopes
}