| 1 | package Perl::Analysis::Static::Analysis::Use; | ||||||||||
| 2 | { | ||||||||||
| 3 | 1 | $Perl::Analysis::Static::Analysis::Use::VERSION = '0.004'; # TRIAL | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | # ABSTRACT: find all module imports via use | ||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use English qw( -no_match_vars ); # Avoids regex performance penalty | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use Perl::Analysis::Static::Element::Use; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | extends 'Perl::Analysis::Static::Analysis'; | |||||||||
| 15 | |||||||||||
| 16 | 1 | has '_ppi_class' => | |||||||||
| 17 | ( is => 'rw', isa => 'Str', default => 'PPI::Statement::Include' ); | ||||||||||
| 18 | |||||||||||
| 19 | 2 | ▶ | sub _convert { | ||||||||
|
Subroutine
_convert: called CC=2 SCAR=7.2
| |||||||||||
| 20 | 2 | my ( $self, $node ) = @_; | |||||||||
| 21 | |||||||||||
| 22 | # get significant children | ||||||||||
| 23 | 2 | my @schildren = $node->schildren(); | |||||||||
| 24 | |||||||||||
| 25 | # the first child is the keyword | ||||||||||
| 26 | 2 | ▶ | unless ( $schildren[0] eq 'use' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | # CHECK: log a warning if this isn't the case? | ||||||||||
| 28 | 0 | return; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | # name is the second child | ||||||||||
| 32 | 2 | my $name = $schildren[1]; | |||||||||
| 33 | |||||||||||
| 34 | 2 | return Perl::Analysis::Static::Element::Use->new( | |||||||||
| 35 | name => $name->content(), | ||||||||||
| 36 | from => $node->location->[0], | ||||||||||
| 37 | to => $node->location->[0], | ||||||||||
| 38 | ppi_node => $node | ||||||||||
| 39 | ); | ||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 1 | 1; | |||||||||
| 43 | |||||||||||
| 44 | __END__ | ||||||||||