begin recursive search for identities with the given name and replace them with e
(id string, e gen.Elem, addID bool)
| 34 | // begin recursive search for identities with the |
| 35 | // given name and replace them with e |
| 36 | func (fs *FileSet) findShim(id string, e gen.Elem, addID bool) { |
| 37 | for name, el := range fs.Identities { |
| 38 | pushstate(name) |
| 39 | switch el := el.(type) { |
| 40 | case *gen.Struct: |
| 41 | for i := range el.Fields { |
| 42 | fs.nextShim(&el.Fields[i].FieldElem, id, e) |
| 43 | } |
| 44 | case *gen.Array: |
| 45 | fs.nextShim(&el.Els, id, e) |
| 46 | case *gen.Slice: |
| 47 | fs.nextShim(&el.Els, id, e) |
| 48 | case *gen.Map: |
| 49 | fs.nextShim(&el.Value, id, e) |
| 50 | if el.Key != nil { |
| 51 | fs.nextShim(&el.Key, id, e) |
| 52 | } |
| 53 | case *gen.Ptr: |
| 54 | fs.nextShim(&el.Value, id, e) |
| 55 | } |
| 56 | popstate() |
| 57 | } |
| 58 | if addID { |
| 59 | fs.Identities[id] = e |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func (fs *FileSet) nextShim(ref *gen.Elem, id string, e gen.Elem) { |
| 64 | if (*ref).TypeName() == id { |
no test coverage detected