Queue<GoTypeName> typeNamesToExplore = new LinkedList<GoTypeName>();
typeNamesToExplore.offer(type);
while ( ! typeNamesToExplore.isEmpty() ) {
GoTypeName currentTypeName = typeNamesToExplore.poll();
receiverTypes.add(currentTypeName);
GoType underlyingType = currentTypeName.underlyingType();
if ( !(underlyingType instanceof GoTypeStruct) )
continue;
GoTypeStruct typeStruct = (GoTypeStruct) underlyingType;
for (GoTypeStructAnonymousField field : typeStruct.getPsiType().getAnonymousFields()) {
GoPsiType psiType = field.getType();
if ( psiType == null)
continue;
if ( psiType instanceof GoPsiTypePointer) {
psiType = ((GoPsiTypePointer) psiType).getTargetType();
}
GoType embeddedType = GoTypes.fromPsi(psiType);
if (!(embeddedType instanceof GoTypeName))
continue;
GoTypeName embeddedTypeName = (GoTypeName) embeddedType;
if (! receiverTypes.contains(embeddedTypeName) )
typeNamesToExplore.offer(embeddedTypeName);
receiverTypes.add(embeddedTypeName);
}