track action applications
Matt S Trout [Mon, 7 Mar 2016 21:28:28 +0000 (21:28 +0000)]
lib/DX/Action/SetBoundValue.pm
lib/DX/Deparse.pm
lib/DX/Hypothesis.pm
lib/DX/QueryState.pm
lib/DX/Role/SimpleAction.pm
lib/DX/ShellSession.pm

index dbc0d75..5771eb7 100644 (file)
@@ -15,7 +15,11 @@ has inner_action => (is => 'ro', required => 1);
 
 sub dry_run {
   my ($self, $hyp) = @_;
-  my ($outer_hyp, @inner_events) = $self->inner_action->dry_run($hyp);
+  my ($outer_hyp, @inner_events) = $self->inner_action->dry_run(
+    $hyp->but(
+      action_applications => [ @{$hyp->action_applications}, $self ],
+    ),
+  );
   my ($scope, @events) = $outer_hyp->scope->apply_updates(
                            DX::Update::SetValue->new(
                              target_path => $self->target_path,
index 1096792..541a5a5 100644 (file)
@@ -115,6 +115,11 @@ sub _fmt_action_bindvalue {
   $self->_fmt_action_generic(BindValue => $action, $meta);
 }
 
+sub _fmt_action_setboundvalue {
+  my ($self, $action, $meta) = @_;
+  $self->_fmt_action_generic(SetBoundValue => $action, $meta);
+}
+
 sub _fmt_action_generic {
   my ($self, $name, $action, $meta) = @_;
   my $path = join '.', map $self->_fmt($_, $meta), @{$action->target_path};
index 71477e8..314cc74 100644 (file)
@@ -19,6 +19,10 @@ has actions => (
   is => 'ro', isa => ArrayRef[Action], required => 1
 );
 
+has action_applications => (
+  is => 'ro', isa => ArrayRef[Action], required => 1
+);
+
 has action_policy => (is => 'ro', isa => ActionPolicy, required => 1);
 
 sub head_proposition { shift->outstanding_propositions->[0] }
@@ -55,6 +59,7 @@ sub but_recheck_for {
     resolved_propositions => DX::ResolvedPropositionSet->new_empty,
     outstanding_propositions => \@recheck,
     actions => [],
+    action_applications => [],
     action_policy => $ap,
   );
 
index b15ac83..6b5061f 100644 (file)
@@ -49,6 +49,7 @@ sub new_search_state_for {
     resolved_propositions => DX::ResolvedPropositionSet->new_empty,
     outstanding_propositions => $prop_seq->members,
     actions => [],
+    action_applications => [],
     action_policy => DX::ActionPolicy::Allow->new,
   );
   return DX::SearchState->new(
index f0b3120..9b6086f 100644 (file)
@@ -17,6 +17,7 @@ sub dry_run {
     $hyp->but(
       scope => $scope,
       actions => [ @{$hyp->actions}, $self ],
+      action_applications => [ @{$hyp->action_applications}, $self ],
     ),
     @events
   );
index d90117a..a703e57 100644 (file)
@@ -116,12 +116,15 @@ sub apply_predicate {
   );
   my $old_qstate = $self->shell_state->current_query_state;
   my $qstate = $old_qstate->with_additional_proposition($prop);
-  my $old_action_count = @{
-    $old_qstate->search_state->current_hypothesis->actions
+  my $old_application_count = @{
+    $old_qstate->search_state->current_hypothesis->action_applications
+  };
+  my @applications = @{
+    $qstate->search_state->current_hypothesis->action_applications
   };
-  my @actions = @{$qstate->search_state->current_hypothesis->actions};
   push our @Result,
-    map [ output => $_ ], @actions[$old_action_count..$#actions];
+    map [ output => $_ ],
+      @applications[$old_application_count..$#applications];
   $self->_set_shell_state(
     $self->shell_state->but(
       current_query_state => $qstate