« Perl/Analysis/Static/Analysis/Declaration/Variable.pm
↑ Summary
Perl/Analysis/Static/ModuleLister.pm »
| 1 | package Perl::Analysis::Static::Analysis; | ||||||||||
| 2 | { | ||||||||||
| 3 | 11 | $Perl::Analysis::Static::Analysis::VERSION = '0.004'; # TRIAL | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | # ABSTRACT: look for certain elements in a Perl document | ||||||||||
| 7 | |||||||||||
| 8 | |||||||||||
| 9 | 11 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 11 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 11 | ▶ | use English qw( -no_match_vars ); # Avoids regex performance penalty | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 11 | has '_ppi_class' => ( is => 'rw', isa => 'Str', default => 'PPI::Node' ); | |||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | 11 | ▶ | sub analyse { | ||||||||
|
Subroutine
analyse: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 17 | 11 | my ( $self, $document ) = @_; | |||||||||
| 18 | |||||||||||
| 19 | # find all nodes of given PPI class | ||||||||||
| 20 | 11 | ▶ | my $nodes = $document->ppi->find( sub { $_[1]->isa( $self->_ppi_class ) } ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | # return immediately if there were no nodes of this class | ||||||||||
| 23 | 11 | ▶ | return unless $nodes; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | # convert them | ||||||||||
| 26 | 11 | my @findings; | |||||||||
| 27 | 11 | for my $node (@$nodes) { | |||||||||
| 28 | 39 | push @findings, $self->_convert($node); | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | # return immediately if we didn't find anything or we get an empty list | ||||||||||
| 32 | 11 | ▶ | return unless @findings; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | |||||||||||
| 34 | 11 | return \@findings; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub _convert { | ||||||||
|
Subroutine
_convert: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | 0 | my ( $self, $ppi_node ) = @_; | |||||||||
| 39 | |||||||||||
| 40 | 0 | die 'implement me'; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 11 | 1; | |||||||||
| 44 | |||||||||||
| 45 | __END__ | ||||||||||