From: Matt S Trout Date: Sat, 16 Jul 2016 20:37:45 +0000 (+0000) Subject: switch recheck completion handling into a step X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=251177ea7e3a1ec49314ffce2846e711052a3fa1;hp=614f3d93fa2a59549c00c849354763a681b8a3e6;p=scpubgit%2FDX.git switch recheck completion handling into a step --- diff --git a/lib/DX/Step/CompleteRecheck.pm b/lib/DX/Step/CompleteRecheck.pm new file mode 100644 index 0000000..f52c194 --- /dev/null +++ b/lib/DX/Step/CompleteRecheck.pm @@ -0,0 +1,34 @@ +package DX::Step::CompleteRecheck; + +use DX::Class; + +with 'DX::Role::Step'; + +has was_recheck_for => (is => 'ro', required => 1); + +has original_search_state => (is => 'ro', required => 1); + +sub apply_to { + my ($self, $ss) = @_; + + my $prop = $self->was_recheck_for; + my $re_ss = $self->original_search_state; + my $re_hyp = $re_ss->current_hypothesis; + my $re_rsp = $re_hyp->resolved_propositions; + + my $rsp = $re_rsp->with_updated_dependencies_for( + $prop, + $ss->current_hypothesis + ->resolved_propositions + ->dependencies_for($prop) + ); + + return $re_ss->but( + current_hypothesis => $re_hyp->but( + resolved_propositions => $rsp + ), + is_solution_state => 1 + ); +} + +1; diff --git a/lib/DX/Step/EnterRecheck.pm b/lib/DX/Step/EnterRecheck.pm index 4b9d76e..64218fa 100644 --- a/lib/DX/Step/EnterRecheck.pm +++ b/lib/DX/Step/EnterRecheck.pm @@ -1,5 +1,7 @@ package DX::Step::EnterRecheck; +use DX::Step::CompleteRecheck; + use DX::Class; with 'DX::Role::Step'; @@ -49,7 +51,10 @@ sub apply_to { ), is_solution_state => 0, on_exhaustion_step => undef, - on_solution_step => DX::Step::MarkAsSolution->new, + on_solution_step => DX::Step::CompleteRecheck->new( + original_search_state => $old_ss, + was_recheck_for => $prop, + ), ); return $ss; diff --git a/lib/DX/Step/ResolveProposition.pm b/lib/DX/Step/ResolveProposition.pm index 900c182..0cd04f1 100644 --- a/lib/DX/Step/ResolveProposition.pm +++ b/lib/DX/Step/ResolveProposition.pm @@ -101,21 +101,7 @@ sub _recheck_one { return undef; } - my $sol_rps = $sol_sp->current_hypothesis->resolved_propositions; - - my $old_hyp = $old_ss->current_hypothesis; - - my $rps = $old_hyp->resolved_propositions; - - $rps = $rps->with_updated_dependencies_for( - $prop, $sol_rps->dependencies_for($prop) - ); - - trace 'step.recheck.done' => 'yay'; - - return $old_ss->but( - current_hypothesis => $old_hyp->but(resolved_propositions => $rps), - ); + return $sol_sp->current_search_state->but(is_solution_state => 0); } 1;