| 1 | package Reply::Plugin::CarpReply; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | $Reply::Plugin::CarpReply::AUTHORITY = 'cpan:DOY'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | { | ||||||||||||||||||||||||||||
| 6 | 1 | $Reply::Plugin::CarpReply::VERSION = '0.08'; | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | # ABSTRACT: plugin that implements most of the functionality of Carp::Reply | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use base 'Reply::Plugin'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Devel::StackTrace::WithLexicals; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 21 | 0 | $self->{stacktrace} = Devel::StackTrace::WithLexicals->new( | |||||||||||||||||||||||||||
| 22 | ignore_class => ['Reply', 'Carp::Reply', __PACKAGE__], | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | 0 | $self->_frame_index(0); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | return $self; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub command_backtrace { | ||||||||||||||||||||||||||
|
Subroutine
command_backtrace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 31 | 0 | print "Backtrace:\n"; | |||||||||||||||||||||||||||
| 32 | 0 | print $self->{stacktrace}; | |||||||||||||||||||||||||||
| 33 | 0 | return ''; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub command_top { | ||||||||||||||||||||||||||
|
Subroutine
command_top: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 38 | 0 | $self->_frame_index($self->{stacktrace}->frame_count - 1); | |||||||||||||||||||||||||||
| 39 | 0 | return ''; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub command_bottom { | ||||||||||||||||||||||||||
|
Subroutine
command_bottom: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 44 | 0 | $self->_frame_index(0); | |||||||||||||||||||||||||||
| 45 | 0 | return ''; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub command_up { | ||||||||||||||||||||||||||
|
Subroutine
command_up: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 50 | 0 | $self->_frame_index($self->{frame_index} + 1); | |||||||||||||||||||||||||||
| 51 | 0 | return ''; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub command_down { | ||||||||||||||||||||||||||
|
Subroutine
command_down: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | 0 | $self->_frame_index($self->{frame_index} - 1); | |||||||||||||||||||||||||||
| 57 | 0 | return ''; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub command_list { | ||||||||||||||||||||||||||
|
Subroutine
command_list: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | 0 | my $file = $self->_frame->filename; | |||||||||||||||||||||||||||
| 63 | 0 | my $line = $self->_frame->line; | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | if (open my $fh, '<', $file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | my @code = <$fh>; | |||||||||||||||||||||||||||
| 66 | 0 | chomp @code; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | my $min = $line - 6; | |||||||||||||||||||||||||||
| 69 | 0 | my $max = $line + 4; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | $min = 0 if $min < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $max = $#code if $max > $#code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | print "File $file:\n"; | |||||||||||||||||||||||||||
| 74 | 0 | for my $cur ($min..$max) { | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | next unless defined $code[$cur]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | printf "%s%*d: %s\n", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | $cur + 1 == $line ? '*' : ' ', | ||||||||||||||||||||||||||||
| 78 | length($max + 1), | ||||||||||||||||||||||||||||
| 79 | $cur + 1, | ||||||||||||||||||||||||||||
| 80 | $code[$cur]; | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | else { | ||||||||||||||||||||||||||||
| 84 | 0 | print "Unable to open $file for reading: $!"; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | return ''; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub command_env { | ||||||||||||||||||||||||||
|
Subroutine
command_env: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | our $env = $self->_frame->lexicals; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | return '$' . __PACKAGE__ . '::env'; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub command_trace { shift->command_backtrace(@_) } | ||||||||||||||||||||||||||
|
Subroutine
command_trace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub command_bt { shift->command_backtrace(@_) } | ||||||||||||||||||||||||||
|
Subroutine
command_bt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub command_t { shift->command_top(@_) } | ||||||||||||||||||||||||||
|
Subroutine
command_t: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub command_b { shift->command_bottom(@_) } | ||||||||||||||||||||||||||
|
Subroutine
command_b: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub command_u { shift->command_up(@_) } | ||||||||||||||||||||||||||
|
Subroutine
command_u: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub command_d { shift->command_down(@_) } | ||||||||||||||||||||||||||
|
Subroutine
command_d: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub command_l { shift->command_list(@_) } | ||||||||||||||||||||||||||
|
Subroutine
command_l: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub lexical_environment { | ||||||||||||||||||||||||||
|
Subroutine
lexical_environment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 108 | 0 | return $self->_frame->lexicals; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub package { | ||||||||||||||||||||||||||
|
Subroutine
package: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 113 | 0 | return $self->_frame->package; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub _frame_index { | ||||||||||||||||||||||||||
|
Subroutine
_frame_index: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 118 | 0 | my ($index) = @_; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if ($index < 0) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 121 | 0 | print "You're already at the bottom frame.\n"; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | elsif ($index >= $self->{stacktrace}->frame_count) { | ||||||||||||||||||||||||||||
| 124 | 0 | print "You're already at the top frame.\n"; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | else { | ||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if (!defined $self->{frame_index} || $self->{frame_index} != $index) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $self->{"frame_index"} or $self->{"frame_index"} != $index
MC/DC0%0/2
not defined $self->{"frame_index"} or $self->{"frame_index"} != $index
not defined $self->{"frame_index"}
$self->{"frame_index"} != $index
Truth table0%0/3
not(A) or B
A= not defined $self->{"frame_index"}B= $self->{"frame_index"} != $index
| |||||||||||||||||||||||||||||
| 128 | 0 | $self->{frame_index} = $index; | |||||||||||||||||||||||||||
| 129 | 0 | printf "Now at %s:%s (frame $index)\n", | |||||||||||||||||||||||||||
| 130 | $self->_frame->filename, | ||||||||||||||||||||||||||||
| 131 | $self->_frame->line; | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub _frame { | ||||||||||||||||||||||||||
|
Subroutine
_frame: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 137 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 138 | 0 | return $self->{stacktrace}->frame($self->{frame_index}); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 1 | 1; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | __END__ | ||||||||||||||||||||||||||||