« lib/Perl/ToPerl6/TransformerParameter/Behavior/String.pm
↑ Summary
lib/Perl/ToPerl6/TransformerListing.pm »
| 1 | package Perl::ToPerl6::Transformer::PostfixExpressions::AddWhitespace; | ||||||||||
| 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 | insert_trailing_whitespace | ||||||||||
| 12 | 17 | }; | |||||||||
| 13 | |||||||||||
| 14 | 17 | ▶ | use base 'Perl::ToPerl6::Transformer'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | #----------------------------------------------------------------------------- | ||||||||||
| 17 | |||||||||||
| 18 | 17 | Readonly::Scalar my $DESC => q{Transform 'if()' to 'if ()'}; | |||||||||
| 19 | 17 | Readonly::Scalar my $EXPL => | |||||||||
| 20 | q{if(), elsif() and unless() need whitespace in order to not be interpreted as function calls}; | ||||||||||
| 21 | |||||||||||
| 22 | #----------------------------------------------------------------------------- | ||||||||||
| 23 | |||||||||||
| 24 | 17 | my %map = ( | |||||||||
| 25 | if => 1, | ||||||||||
| 26 | elsif => 1, | ||||||||||
| 27 | unless => 1, | ||||||||||
| 28 | while => 1, | ||||||||||
| 29 | until => 1, | ||||||||||
| 30 | for => 1, | ||||||||||
| 31 | foreach => 1, | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | #----------------------------------------------------------------------------- | ||||||||||
| 35 | |||||||||||
| 36 | 38 | ▶ | sub supported_parameters { return () } | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 37 | 26 | ▶ | sub default_necessity { return $NECESSITY_HIGHEST } | ||||||||
|
Subroutine
default_necessity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | 24 | ▶ | sub default_themes { return qw( core ) } | ||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 5 | ▶ | sub applies_to { | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 40 | 78 | ▶ | return sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 41 | 78 | ▶ | is_ppi_token_word($_[1],%map) and | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | $_[1]->next_sibling->isa('PPI::Structure::Condition') | ||||||||||
| 43 | } | ||||||||||
| 44 | 5 | } | |||||||||
| 45 | |||||||||||
| 46 | #----------------------------------------------------------------------------- | ||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub transform { | ||||||||
|
Subroutine
transform: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 49 | 0 | my ($self, $elem, $doc) = @_; | |||||||||
| 50 | |||||||||||
| 51 | 0 | insert_trailing_whitespace($elem); | |||||||||
| 52 | |||||||||||
| 53 | 0 | return $self->transformation( $DESC, $EXPL, $elem ); | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 17 | 1; | |||||||||
| 57 | |||||||||||
| 58 | #----------------------------------------------------------------------------- | ||||||||||
| 59 | |||||||||||
| 60 | __END__ | ||||||||||