| 1 | # -*- coding: utf-8 -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright (C) 2014 Rocky Bernstein <rocky@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Part of Devel::Trepan::CmdProcessor that loads up debugger commands from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # builtin and user directories. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Top-level command completion routines. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use rlib '../../..'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | package Devel::Trepan::CmdProcessor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use warnings; use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 12 | ▶ | use Devel::Trepan::Complete; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 12 | my $_list_complete_i = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | sub list_complete($$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_complete: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | my($self, $text, $state) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_complete: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # clear counter at the first call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | eval { state $_list_complete_i = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | $_list_complete_i++;; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $cw = $self->{completions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | for (; $_list_complete_i <= $#{$cw}; $_list_complete_i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return $cw->[$_list_complete_i] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
defined $cw->[$_list_complete_i] and $cw->[$_list_complete_i] =~ /^\Q$text\E/
defined $cw->[$_list_complete_i] and $cw->[$_list_complete_i] =~ /^\Q$text\E/
MC/DC0%0/2
defined $cw->[$_list_complete_i] and $cw->[$_list_complete_i] =~ /^\Q$text\E/
defined $cw->[$_list_complete_i]
$cw->[$_list_complete_i] =~ /^\Q$text\E/
MC/DC0%0/2
defined $cw->[$_list_complete_i] and $cw->[$_list_complete_i] =~ /^\Q$text\E/
defined $cw->[$_list_complete_i]
$cw->[$_list_complete_i] =~ /^\Q$text\E/
Truth table0%0/3
A and B
A= defined $cw->[$_list_complete_i]B= $cw->[$_list_complete_i] =~ /^\Q$text\E/
Truth table0%0/3
A and B
A= defined $cw->[$_list_complete_i]B= $cw->[$_list_complete_i] =~ /^\Q$text\E/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | if defined $cw->[$_list_complete_i] and ($cw->[$_list_complete_i] =~ /^\Q$text/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 12 | my ($_last_line, $_last_start, $_last_end, @_last_return, $_last_token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # Handle initial completion. We draw from the commands, aliases, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # and macros for completion. However we won't include aliases which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # are prefixes of other commands. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | sub complete($$$$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete: called CC=21 SCAR=49.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my ($self, $text, $line, $start, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete: not called CC=21 SCAR=49.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->{leading_str} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $_last_line = '' unless defined $_last_line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $_last_start = -1 unless defined $_last_start; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $_last_end = -1 unless defined $_last_end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $_last_token = '' unless defined $_last_token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $_last_token = '' unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$_last_start < length $line and 0 == index(substr($line, $_last_start), $_last_token)
$_last_start < length $line and 0 == index(substr($line, $_last_start), $_last_token)
MC/DC50%1/2
$_last_start < length $line and 0 == index(substr($line, $_last_start), $_last_token)
$_last_start < length $line
0 == index(substr($line, $_last_start), $_last_token)
MC/DC0%0/2
$_last_start < length $line and 0 == index(substr($line, $_last_start), $_last_token)
$_last_start < length $line
0 == index(substr($line, $_last_start), $_last_token)
Truth table66%2/3
A and B
A= $_last_start < length $lineB= 0 == index(substr($line, $_last_start), $_last_token)
Truth table0%0/3
A and B
A= $_last_start < length $lineB= 0 == index(substr($line, $_last_start), $_last_token)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | $_last_start < length($line) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 == index(substr($line, $_last_start), $_last_token); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # print "\ntext: $text, line: $line, start: $start, end: $end\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # print "\nlast_line: $_last_line, last_start: $_last_start, last_end: $last_end\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $stripped_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ($stripped_line = $line) =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($_last_line eq $stripped_line && $stripped_line) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
$_last_line eq $stripped_line and $stripped_line
$_last_line eq $stripped_line and $stripped_line
MC/DC0%0/2
$_last_line eq $stripped_line and $stripped_line
$_last_line eq $stripped_line
$stripped_line
MC/DC0%0/2
$_last_line eq $stripped_line and $stripped_line
$_last_line eq $stripped_line
$stripped_line
Truth table33%1/3
A and B
A= $_last_line eq $stripped_lineB= $stripped_line
Truth table0%0/3
A and B
A= $_last_line eq $stripped_lineB= $stripped_line
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->{completions} = \@_last_return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return @_last_return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ($_last_line, $_last_start, $_last_end) = ($line, $start, $end); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my @commands = sort keys %{$self->{commands}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my ($next_blank_pos, $token) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | Devel::Trepan::Complete::next_token($line, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (!$token && !$_last_token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
$token or $_last_token
$token or $_last_token
MC/DC0%0/2
$token or $_last_token
$token
$_last_token
MC/DC0%0/2
$token or $_last_token
$token
$_last_token
Truth table33%1/3
A or B
A= $tokenB= $_last_token
Truth table0%0/3
A or B
A= $tokenB= $_last_token
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | @_last_return = @commands; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $_last_token = $_last_return[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $_last_line = $line . $_last_token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $_last_end += length($_last_token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $self->{completions} = \@_last_return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return (@commands); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | $token ||= $_last_token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
$token ||= $_last_token
$token ||= $_last_token
MC/DC0%0/2
$token ||= $_last_token
$token
$_last_token
MC/DC0%0/2
$token ||= $_last_token
$token
$_last_token
Truth table33%1/3
A ||= B
A= $tokenB= $_last_token
Truth table0%0/3
A ||= B
A= $tokenB= $_last_token
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my @match_pairs = complete_token_with_next($self->{commands}, $token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $match_hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | for my $pair (@match_pairs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $match_hash->{$pair->[0]} = $pair->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | my @alias_pairs = complete_token_filtered_with_next($self->{aliases}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | $token, $match_hash, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->{commands}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | push @match_pairs, @alias_pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($next_blank_pos >= length($line)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | @_last_return = sort map {$_->[0]} @match_pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $_last_token = $_last_return[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if (defined($_last_token)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $_last_line = $line . $_last_token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $_last_end += length($_last_token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if (scalar @_last_return == 0 && $self->{settings}{autoeval}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
scalar @_last_return == 0 and $self->{"settings"}{"autoeval"}
scalar @_last_return == 0 and $self->{"settings"}{"autoeval"}
MC/DC0%0/2
scalar @_last_return == 0 and $self->{"settings"}{"autoeval"}
scalar @_last_return == 0
$self->{"settings"}{"autoeval"}
MC/DC0%0/2
scalar @_last_return == 0 and $self->{"settings"}{"autoeval"}
scalar @_last_return == 0
$self->{"settings"}{"autoeval"}
Truth table33%1/3
A and B
A= scalar @_last_return == 0B= $self->{"settings"}{"autoeval"}
Truth table0%0/3
A and B
A= scalar @_last_return == 0B= $self->{"settings"}{"autoeval"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return Devel::Trepan::Complete::complete_subs($stripped_line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $self->{completions} = \@_last_return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return @_last_return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | for my $pair (@alias_pairs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $match_hash->{$pair->[0]} = $pair->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (scalar(@match_pairs) > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # FIXME: figure out what to do here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # Matched multiple items in the middle of the string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # We can't handle this so do nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # return match_pairs.map do |name, cmd| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # ["#{name} #{args[1..-1].join(' ')}"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # scalar @match_pairs == 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | @_last_return = $self->next_complete($line, $next_blank_pos, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | $match_pairs[0]->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | $token); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->{completions} = \@_last_return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if (scalar @_last_return == 0 && $self->{settings}{autoeval}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
scalar @_last_return == 0 and $self->{"settings"}{"autoeval"}
scalar @_last_return == 0 and $self->{"settings"}{"autoeval"}
MC/DC50%1/2
scalar @_last_return == 0 and $self->{"settings"}{"autoeval"}
scalar @_last_return == 0
$self->{"settings"}{"autoeval"}
MC/DC0%0/2
scalar @_last_return == 0 and $self->{"settings"}{"autoeval"}
scalar @_last_return == 0
$self->{"settings"}{"autoeval"}
Truth table66%2/3
A and B
A= scalar @_last_return == 0B= $self->{"settings"}{"autoeval"}
Truth table0%0/3
A and B
A= scalar @_last_return == 0B= $self->{"settings"}{"autoeval"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return Devel::Trepan::Complete::complete_subs($stripped_line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return @_last_return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | sub next_complete($$$$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 20 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_complete: called CC=18 SCAR=46.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my($self, $str, $next_blank_pos, $cmd, $last_token) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_complete: not called CC=18 SCAR=46.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ($next_blank_pos, $token) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | Devel::Trepan::Complete::next_token($str, $next_blank_pos); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return () if !$token && !$last_token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$token or $last_token
$token or $last_token
MC/DC0%0/2
$token or $last_token
$token
$last_token
MC/DC0%0/2
$token or $last_token
$token
$last_token
Truth table66%2/3
A or B
A= $tokenB= $last_token
Truth table0%0/3
A or B
A= $tokenB= $last_token
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return () unless defined($cmd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return @{$cmd} if ref($cmd) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | return $cmd->($token) if (ref($cmd) eq 'CODE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ($cmd->can("complete_token_with_next")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my @match_pairs = $cmd->complete_token_with_next($token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | return () unless scalar @match_pairs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($next_blank_pos >= length($str)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | return map {$_->[0]} @match_pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if (scalar @match_pairs == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ($next_blank_pos == length($str)-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition33%2/6
$next_blank_pos == length($str) - 1 and " " ne substr($str, length($str) - 1)
$next_blank_pos == length($str) - 1 and " " ne substr($str, length($str) - 1)
MC/DC0%0/2
$next_blank_pos == length($str) - 1 and " " ne substr($str, length($str) - 1)
$next_blank_pos == length($str) - 1
" " ne substr($str, length($str) - 1)
MC/DC0%0/2
$next_blank_pos == length($str) - 1 and " " ne substr($str, length($str) - 1)
$next_blank_pos == length($str) - 1
" " ne substr($str, length($str) - 1)
Truth table66%2/3
A and B
A= $next_blank_pos == length($str) - 1B= " " ne substr($str, length($str) - 1)
Truth table0%0/3
A and B
A= $next_blank_pos == length($str) - 1B= " " ne substr($str, length($str) - 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | && ' ' ne substr($str, length($str)-1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return map {$_->[0]} @match_pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } elsif ($match_pairs[0]->[0] eq $token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return $self->next_complete($str, $next_blank_pos, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | $match_pairs[0]->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $token); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # FIXME: figure out what to do here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # Matched multiple items in the middle of the string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # We can't handle this so do nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } elsif ($cmd->can('complete')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my @matches = $cmd->complete($token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | return () unless scalar @matches; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if (substr($str, $next_blank_pos) =~ /\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if (1 == scalar(@matches) && $matches[0] eq $token) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
1 == scalar @matches and $matches[0] eq $token
1 == scalar @matches and $matches[0] eq $token
MC/DC100%2/2
1 == scalar @matches and $matches[0] eq $token
1 == scalar @matches
$matches[0] eq $token
MC/DC0%0/2
1 == scalar @matches and $matches[0] eq $token
1 == scalar @matches
$matches[0] eq $token
Truth table100%3/3
A and B
A= 1 == scalar @matchesB= $matches[0] eq $token
Truth table0%0/3
A and B
A= 1 == scalar @matchesB= $matches[0] eq $token
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # Nothing more to complete. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | return @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # FIXME: figure out what to do here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # Matched multiple items in the middle of the string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # We can't handle this so do nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub filename_complete($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename_complete: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | my ($self, $prefix) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename_complete: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{interfaces}[-1]->rl_filename_list($prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 12 | ▶ | unless (caller) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | require Devel::Trepan::CmdProcessor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my $cmdproc = Devel::Trepan::CmdProcessor->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # $cmdproc->run_cmd(['list', 5]); # Invalid - nonstring arg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | printf "complete('s') => %s\n", join(', ', $cmdproc->complete("s", 's', 0, 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | printf "complete('') => %s\n", join(', ', $cmdproc->complete("", '', 0, 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | printf "complete('help se') => %s\n", join(', ', $cmdproc->complete("help se", 'help se', 0, 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub complete_it($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_it: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | my ($cmdproc, $str) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_it: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my @c = $cmdproc->complete($str, $str, 0, length($str)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | printf "complete('$str') => %s\n", join(', ', @c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return @c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my @c = complete_it($cmdproc, "set "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | @c = complete_it($cmdproc, "help set base"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | @c = complete_it($cmdproc, "set basename on "); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $str = './'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | @c = $cmdproc->filename_complete($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | printf "complete('$str') => %s\n", join(', ', @c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||