func (a *API) renameExportable() {
	for name, op := range a.Operations {
		newName := a.ExportableName(name)
		if newName != name {
			delete(a.Operations, name)
			a.Operations[newName] = op
		}
		op.ExportedName = newName
	}
	for k, s := range a.Shapes {
		if s.Type == "string" {
			continue
		}
		for mName, member := range s.MemberRefs {
			newName := a.ExportableName(mName)
			if newName != mName {
				delete(s.MemberRefs, mName)
				s.MemberRefs[newName] = member
				if member.LocationName == "" && member.Shape.LocationName == "" {
					member.LocationName = mName
				}
			}
			if newName == "SDKShapeTraits" {
				panic("Shape " + s.ShapeName + " uses reserved member name SDKShapeTraits")
			}
		}
		newName := a.ExportableName(k)
		if newName != s.ShapeName {
			s.Rename(newName)
		}
		s.Payload = a.ExportableName(s.Payload)
		for i, n := range s.Required {
			s.Required[i] = a.ExportableName(n)
		}
	}
}
renameExportable renames all operation names to be exportable names.
All nested Shape names are also updated to the exportable variant.
package api
import (
	"fmt"
	"regexp"
)
func (a *API) updateTopLevelShapeReferences() {
	for _, o := range a.Operations {
		if o.InputRef.LocationName != "" {
			o.InputRef.Shape.LocationName = o.InputRef.LocationName
		}
		if o.InputRef.Location != "" {
			o.InputRef.Shape.Location = o.InputRef.Location
		}
		if o.InputRef.Payload != "" {
			o.InputRef.Shape.Payload = o.InputRef.Payload
		}
		if o.InputRef.XMLNamespace.Prefix != "" {
			o.InputRef.Shape.XMLNamespace.Prefix = o.InputRef.XMLNamespace.Prefix
		}
		if o.InputRef.XMLNamespace.URI != "" {
			o.InputRef.Shape.XMLNamespace.URI = o.InputRef.XMLNamespace.URI
		}
	}
}
func (a *API) writeShapeNames() {
	for n, s := range a.Shapes {
		s.API = a
		s.ShapeName = n
	}
}
func (a *API) resolveReferences() {
	resolver := referenceResolver{API: a, visited: map[*ShapeRef]bool{}}
	for _, s := range a.Shapes {
		resolver.resolveShape(s)
	}
	for _, o := range a.Operations {
		o.API = a  
		resolver.resolveReference(&o.InputRef)
		resolver.resolveReference(&o.OutputRef)
	}
}
type referenceResolver struct {
	*API
	visited map[*ShapeRef]bool
}
func (r *referenceResolver) resolveReference(ref *ShapeRef) {
	if ref.ShapeName == "" {
		return
	}
	if shape, ok := r.API.Shapes[ref.ShapeName]; ok {
		ref.API = r.API    
		ref.Shape = shape  
		if r.visited[ref] {
			return
		}
		r.visited[ref] = true
		shape.refs = append(shape.refs, ref)  
		r.resolveShape(shape)
	}
}
func (r *referenceResolver) resolveShape(shape *Shape) {
	r.resolveReference(&shape.MemberRef)
	r.resolveReference(&shape.KeyRef)
	r.resolveReference(&shape.ValueRef)
	for _, m := range shape.MemberRefs {
		r.resolveReference(m)
	}
}
func (a *API) renameToplevelShapes() {
	for _, v := range a.Operations {
		if v.HasInput() && !a.NoInflections {
			name := v.ExportedName + "Input"
			switch n := len(v.InputRef.Shape.refs); {
			case n == 1 && a.Shapes[name] == nil:
				v.InputRef.Shape.Rename(name)
			}
		}
		if v.HasOutput() && !a.NoInflections {
			name := v.ExportedName + "Output"
			switch n := len(v.OutputRef.Shape.refs); {
			case n == 1 && a.Shapes[name] == nil:
				v.OutputRef.Shape.Rename(name)
			}
		}
		v.InputRef.Payload = a.ExportableName(v.InputRef.Payload)
		v.OutputRef.Payload = a.ExportableName(v.OutputRef.Payload)
	}
}
func (a *API) fixStutterNames() {
	re := regexp.MustCompile(fmt.Sprintf(`\A(?i:%s)`, a.PackageName()))
	for name, op := range a.Operations {
		newName := re.ReplaceAllString(name, "")
		if newName != name {
			delete(a.Operations, name)
			a.Operations[newName] = op
		}
		op.ExportedName = newName
	}
	for k, s := range a.Shapes {
		newName := re.ReplaceAllString(k, "")
		if newName != s.ShapeName {
			s.Rename(newName)
		}
	}
}