« lib/Perl/ToPerl6/Transformer/Arrays/AddWhitespace.pm
↑ Summary
lib/Perl/ToPerl6/Transformer/Builtins/Rename.pm »
| 1 | package Perl::ToPerl6::Transformer::CompoundStatements::RenameForeach; | ||
| 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{ is_ppi_statement_compound }; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 17 | ▶ | use base 'Perl::ToPerl6::Transformer'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | #----------------------------------------------------------------------------- | ||
| 14 | |||
| 15 | 17 | Readonly::Scalar my $DESC => q{Transform 'foreach' to 'for'}; | |
| 16 | 17 | Readonly::Scalar my $EXPL => q{foreach() is now nmaed for()}; | |
| 17 | |||
| 18 | #----------------------------------------------------------------------------- | ||
| 19 | |||
| 20 | 17 | my %map = ( | |
| 21 | foreach => 'for', | ||
| 22 | ); | ||
| 23 | |||
| 24 | #----------------------------------------------------------------------------- | ||
| 25 | |||
| 26 | 38 | ▶ | sub supported_parameters { return () } |
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 27 | 26 | ▶ | sub default_necessity { return $NECESSITY_HIGHEST } |
|
Subroutine
default_necessity: called CC=1 SCAR=0.0
Pod
documented
| |||
| 28 | 24 | ▶ | sub default_themes { return qw( core ) } |
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||
| 29 | 5 | ▶ | sub applies_to { |
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||
| 30 | 78 | ▶ | return sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 31 | 78 | is_ppi_statement_compound($_[1], %map) | |
| 32 | } | ||
| 33 | 5 | } | |
| 34 | |||
| 35 | #----------------------------------------------------------------------------- | ||
| 36 | |||
| 37 | 0 | ▶ | sub transform { |
|
Subroutine
transform: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 38 | 0 | my ($self, $elem, $doc) = @_; | |
| 39 | |||
| 40 | 0 | my $old_content = $elem->schild(0)->content; | |
| 41 | |||
| 42 | 0 | $elem->schild(0)->set_content($map{$old_content}); | |
| 43 | |||
| 44 | 0 | return $self->transformation( $DESC, $EXPL, $elem ); | |
| 45 | } | ||
| 46 | |||
| 47 | 17 | 1; | |
| 48 | |||
| 49 | #----------------------------------------------------------------------------- | ||
| 50 | |||
| 51 | __END__ | ||