File Coverage

blib/lib/PLS/Parser/Element/Subroutine.pm
Criterion Covered Total %
statement 12 33 36.3
branch 0 14 0.0
condition n/a
subroutine 4 9 44.4
pod 3 4 75.0
total 19 60 31.6


line stmt bran cond sub pod time code
1              
2             use strict;
3 11     11   56 use warnings;
  11         20  
  11         240  
4 11     11   43  
  11         20  
  11         216  
5             use parent 'PLS::Parser::Element';
6 11     11   43  
  11         21  
  11         43  
7             use List::Util qw(any);
8 11     11   482  
  11         21  
  11         3865  
9             =head1 NAME
10              
11             PLS::Parser::Element::Subroutine
12              
13             =head1 DESCRIPTION
14              
15             Subclass of L<PLS::Parser::Element> representing a subroutine declaration.
16              
17             =cut
18              
19             {
20             my ($self) = @_;
21              
22 0     0 1   my $info = $self->SUPER::location_info;
23              
24 0           my $signature = $self->signature;
25             $info->{signature} = $signature if (ref $signature eq 'HASH');
26 0            
27 0 0         return $info;
28             } ## end sub location_info
29 0            
30             {
31             my ($self) = @_;
32              
33             my $block = $self->element->block;
34 0     0 0   return unless (ref $block eq 'PPI::Structure::Block');
35              
36 0           # only looking at first variable statement, for performance sake.
37 0 0         foreach my $child ($block->children)
38             {
39             next unless $child->isa('PPI::Statement::Variable');
40 0           return unless $child->type eq 'my';
41             return
42 0 0         unless any { $_->isa('PPI::Token::Magic') and $_->content eq '@_' }
43 0 0         $child->children;
44             return unless (scalar $child->variables);
45 0 0   0     return {label => $child->content, parameters => [map { {label => $_} } $child->variables]};
46 0 0         } ## end foreach my $child ($block->...)
47 0 0          
48 0           return;
  0            
49             } ## end sub signature
50              
51 0           {
52             my ($self) = @_;
53              
54             return $self->element->name;
55             }
56 0     0 1    
57             {
58 0           my ($self) = @_;
59              
60             return $self->SUPER::length() + length('sub ');
61             }
62              
63 0     0 1   1;