From: Matt S Trout Date: Mon, 7 Mar 2016 21:28:28 +0000 (+0000) Subject: track action applications X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e442aff87e6f5ffbad70a825d9ddade8a4da82fc;p=scpubgit%2FDX.git track action applications --- diff --git a/lib/DX/Action/SetBoundValue.pm b/lib/DX/Action/SetBoundValue.pm index dbc0d75..5771eb7 100644 --- a/lib/DX/Action/SetBoundValue.pm +++ b/lib/DX/Action/SetBoundValue.pm @@ -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, diff --git a/lib/DX/Deparse.pm b/lib/DX/Deparse.pm index 1096792..541a5a5 100644 --- a/lib/DX/Deparse.pm +++ b/lib/DX/Deparse.pm @@ -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}; diff --git a/lib/DX/Hypothesis.pm b/lib/DX/Hypothesis.pm index 71477e8..314cc74 100644 --- a/lib/DX/Hypothesis.pm +++ b/lib/DX/Hypothesis.pm @@ -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, ); diff --git a/lib/DX/QueryState.pm b/lib/DX/QueryState.pm index b15ac83..6b5061f 100644 --- a/lib/DX/QueryState.pm +++ b/lib/DX/QueryState.pm @@ -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( diff --git a/lib/DX/Role/SimpleAction.pm b/lib/DX/Role/SimpleAction.pm index f0b3120..9b6086f 100644 --- a/lib/DX/Role/SimpleAction.pm +++ b/lib/DX/Role/SimpleAction.pm @@ -17,6 +17,7 @@ sub dry_run { $hyp->but( scope => $scope, actions => [ @{$hyp->actions}, $self ], + action_applications => [ @{$hyp->action_applications}, $self ], ), @events ); diff --git a/lib/DX/ShellSession.pm b/lib/DX/ShellSession.pm index d90117a..a703e57 100644 --- a/lib/DX/ShellSession.pm +++ b/lib/DX/ShellSession.pm @@ -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