(doc *T, component *ExampleRef, documentPath *url.URL)
| 1154 | } |
| 1155 | |
| 1156 | func (loader *Loader) resolveExampleRef(doc *T, component *ExampleRef, documentPath *url.URL) (err error) { |
| 1157 | if ref := component.Ref; ref != "" { |
| 1158 | if component.Value != nil { |
| 1159 | return nil |
| 1160 | } |
| 1161 | if !loader.shouldVisitRef(ref, func(value any) { |
| 1162 | component.Value = value.(*Example) |
| 1163 | refPath, _ := loader.resolveRefPath(ref, documentPath) |
| 1164 | component.setRefPath(refPath) |
| 1165 | }) { |
| 1166 | return nil |
| 1167 | } |
| 1168 | loader.visitRef(ref) |
| 1169 | if isSingleRefElement(ref) { |
| 1170 | var example Example |
| 1171 | if _, err = loader.loadSingleElementFromURI(ref, documentPath, &example); err != nil { |
| 1172 | return err |
| 1173 | } |
| 1174 | component.Value = &example |
| 1175 | component.setRefPath(documentPath) |
| 1176 | } else { |
| 1177 | var resolved ExampleRef |
| 1178 | doc, componentPath, err := loader.resolveComponent(doc, ref, documentPath, &resolved) |
| 1179 | if err != nil { |
| 1180 | return err |
| 1181 | } |
| 1182 | if err := loader.resolveExampleRef(doc, &resolved, componentPath); err != nil { |
| 1183 | if err == errMUSTExample { |
| 1184 | return nil |
| 1185 | } |
| 1186 | return err |
| 1187 | } |
| 1188 | component.Value = resolved.Value |
| 1189 | component.setRefPath(resolved.RefPath()) |
| 1190 | } |
| 1191 | defer loader.unvisitRef(ref, component.Value) |
| 1192 | } |
| 1193 | return nil |
| 1194 | } |
| 1195 | |
| 1196 | func (loader *Loader) resolveCallbackRef(doc *T, component *CallbackRef, documentPath *url.URL) (err error) { |
| 1197 | if component.isEmpty() { |
no test coverage detected