| 1 | package Reply::Plugin::Autocomplete::Lexicals; | ||||||||||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:DOY'; | |||||||||||||||||||||||||||
| 3 | 1 | $Reply::Plugin::Autocomplete::Lexicals::VERSION = '0.42'; | |||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | # ABSTRACT: tab completion for lexical variables | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use base 'Reply::Plugin'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Reply::Util qw($varname_rx); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub tab_handler { | ||||||||||||||||||||||||||
|
Subroutine
tab_handler: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 15 | 0 | my ($line) = @_; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | my ($var) = $line =~ /($varname_rx)$/; | |||||||||||||||||||||||||||
| 18 | 0 | ▶ | return unless $var; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | my ($sigil, $name_prefix) = $var =~ /(.)(.*)/; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # these can't be lexicals | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | return if $sigil eq '&' || $sigil eq '*'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sigil eq "&" or $sigil eq "*"
MC/DC0%0/2
$sigil eq "&" or $sigil eq "*"
$sigil eq "&"
$sigil eq "*"
Truth table0%0/3
A or B
A= $sigil eq "&"B= $sigil eq "*"
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | my $env = { map { %$_ } $self->publish('lexical_environment') }; | |||||||||||||||||||||||||||
| 26 | 0 | my @env = keys %$env; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | my @results; | |||||||||||||||||||||||||||
| 29 | 0 | for my $env_var (@env) { | |||||||||||||||||||||||||||
| 30 | 0 | my ($env_sigil, $env_name) = $env_var =~ /(.)(.*)/; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | next unless index($env_name, $name_prefix) == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # this is weird, not sure why % gets stripped but not $ or @ | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ($sigil eq $env_sigil) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | push @results, $sigil eq '%' ? $env_var : $env_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | ▶ | elsif ($env_sigil eq '@' && $sigil eq '$') { | |||||||||||||||||||||||||||
|
Condition0%0/3
$env_sigil eq "\@" and $sigil eq "\$"
MC/DC0%0/2
$env_sigil eq "\@" and $sigil eq "\$"
$env_sigil eq "\@"
$sigil eq "\$"
Truth table0%0/3
A and B
A= $env_sigil eq "\@"B= $sigil eq "\$"
| |||||||||||||||||||||||||||||
| 39 | 0 | push @results, "$env_name\["; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | elsif ($env_sigil eq '%') { | ||||||||||||||||||||||||||||
| 42 | 0 | push @results, "$env_name\{"; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | return @results; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 1 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||