MCPcopy Create free account
hub / github.com/google/gapid / correlateNodes

Function correlateNodes

gapil/bapi/bapi_test.go:107–122  ·  view source on GitHub ↗

correlateNodes traverses the from and to API trees to build and return a map that translates all the nodes in from to to. This function requires the two trees to be symmetrical.

(from, to []*semantic.API)

Source from the content-addressed store, hash-verified

105// that translates all the nodes in from to to. This function requires the two
106// trees to be symmetrical.
107func correlateNodes(from, to []*semantic.API) map[semantic.Node]semantic.Node {
108 out := make(map[semantic.Node]semantic.Node)
109 for i := range from {
110 f, t := collectNodes(from[i]), collectNodes(to[i])
111 if len(f) != len(t) {
112 panic("APIs are not balanced")
113 }
114 for i, n := range f {
115 if reflect.TypeOf(n) != reflect.TypeOf(t[i]) {
116 panic("APIs are not symmetrical")
117 }
118 out[n] = t[i]
119 }
120 }
121 return out
122}
123
124func collectNodes(n semantic.Node) []semantic.Node {
125 l := []semantic.Node{}

Callers 1

translateMappingFunction · 0.85

Calls 2

collectNodesFunction · 0.85
TypeOfMethod · 0.45

Tested by

no test coverage detected