code: func NewPlan(changes *plans.Changes) *Plan {
  	log.Printf("[TRACE] NewPlan for %#v", changes)
  	ret := &Plan{}
  	if changes == nil {
  		// Nothing to do!
  		return ret
  	}
  
  	for _, rc := range changes.Resources {
  		addr := rc.Addr
  		log.Printf("[TRACE] NewPlan found %s (%s)", addr, rc.Action)
  		dataSource := addr.Resource.Resource.Mode == addrs.DataResourceMode
  
  		// We create "delete" actions for data resources so we can clean
  		// up their entries in state, but this is an implementation detail
  		// that users shouldn't see.
  		if dataSource && rc.Action == plans.Delete {
  			continue
  		}
  
  		// For now we'll shim this to work with our old types.
  		// TODO: Update for the new plan types, ideally also switching over to
  		// a structural diff renderer instead of a flat renderer.
  		did := &InstanceDiff{
  			Addr:   terraform.NewLegacyResourceInstanceAddress(addr),
  			Action: rc.Action,
  		}
  
  		if rc.DeposedKey != states.NotDeposed {
  			did.Deposed = true
  		}
  
  		// Since this is just a temporary stub implementation on the way
  		// to us replacing this with the structural diff renderer, we currently
  		// don't include any attributes here.
  		// FIXME: Implement the structural diff renderer to replace this
  		// codepath altogether.
  
  		ret.Resources = append(ret.Resources, did)
  	}
  
  	// Sort the instance diffs by their addresses for display.
  	sort.Slice(ret.Resources, func(i, j int) bool {
  		iAddr := ret.Resources[i].Addr
  		jAddr := ret.Resources[j].Addr
  		return iAddr.Less(jAddr)
  	})
  
  	return ret
  }
docs: // NewPlan produces a display-oriented Plan from a terraform.Plan.