lib/Perl/ToPerl6/Transformer/Packages/RewriteDeclarations.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 12 / 12 Podpod 60.0% 3 / 5 totaltotal 93.4% 57 / 61 CC 4 SCAR 5.9
CC
4
Cov
98%
transform
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« lib/Perl/ToPerl6/Transformer/Regexes/SwapModifiers.pm ↑ Summary lib/Perl/ToPerl6/Utils/DataConversion.pm »
1 package Perl::ToPerl6::Transformer::Packages::RewriteDeclarations;
2  
3 17 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶use Perl::ToPerl6::Utils qw{ :severities };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use Perl::ToPerl6::Utils::PPI qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
10 is_ppi_token_word
11 is_package_boundary
12 make_ppi_structure_block
13 17 };
14  
15 17 ▶use base 'Perl::ToPerl6::Transformer';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 #-----------------------------------------------------------------------------
18  
19 17 Readonly::Scalar my $DESC => q{Transform 'package' declaration into 'class'};
20 17 Readonly::Scalar my $EXPL => q{The Perl6 equivalent of packages are classes.};
21  
22 #-----------------------------------------------------------------------------
23  
24 38 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
25 27 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
26 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
27 5 ▶sub applies_to { return 'PPI::Document' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
28  
29 #-----------------------------------------------------------------------------
30  
31 # Just make this a document-level processor for the time being.
32 #
33 5 ▶sub transform {
Subroutine transform: called CC=4 SCAR=13.9
Pod undocumented
34 5 my ($self, $elem, $doc) = @_;
35  
36 5 my $ref = $doc->find('PPI::Statement::Package');
37 5 ▶ if ( $ref and @{ $ref } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref and @{$ref;}) 1 4 5
Condition66%2/3
$ref and @{$ref;}
!ll&&!rl&&r
401
MC/DC50%1/2
$ref and @{$ref;}
$ref @{$ref;}
Truth table66%2/3
A and B
A= $refB= @{$ref;}
ABresult
0X0
100
111
38 1 my @package = @{ $ref };
39 1 for my $package ( @package ) {
40 1 $package->schild(0)->set_content('unit class');
41  
42 # if ( $package->schild(2) and
43 # $package->schild(2)->isa('PPI::Token::Structure') and
44 # $package->schild(2)->content eq ';' ) {
45 #
46 # my $new_block = make_ppi_structure_block;
47 # my $new_statement = PPI::Statement->new;
48 # $new_block->add_element($new_statement);
49 #
50 # my $token = $package->next_sibling;
51 # while ( $token and $token->next_sibling ) {
52 # last if is_package_boundary($token);
53 # $new_statement->add_element($token->clone);
54 # $token = $token->next_sibling;
55 # }
56 #
57 # my $point = $package->next_sibling;
58 # while ( $point and
59 # not is_package_boundary($point) ) {
60 # my $temp = $point->next_sibling;
61 # $point->remove;
62 # $point = $temp;
63 # }
64 # $package->last_element->insert_before($new_block);
65 # }
66 }
67 1 return $self->transformation( $DESC, $EXPL, $elem );
68 }
69  
70 4 return;
71 }
72  
73 17 1;
74  
75 #-----------------------------------------------------------------------------
76  
77 __END__
« lib/Perl/ToPerl6/Transformer/Regexes/SwapModifiers.pm ↑ Summary lib/Perl/ToPerl6/Utils/DataConversion.pm »