| 1 | package PPIx::QuoteLike::Token::Interpolation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use PPI::Document; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use PPIx::QuoteLike::Constant qw{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | LOCATION_COLUMN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | LOCATION_LOGICAL_LINE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | LOCATION_LOGICAL_FILE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | @CARP_NOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use PPIx::QuoteLike::Utils qw{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | __normalize_interpolation_for_ppi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | __variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | ▶ | use base qw{ PPIx::QuoteLike::Token }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | our $VERSION = '0.024'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 57 | ▶ | sub ppi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ppi: called CC=12 SCAR=26.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 57 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 57 | ▶ | unless ( $self->{ppi} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 34 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 34 | my $location = $self->{location}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 34 | ▶ | if ( $location ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 13 | my $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 13 | ▶ | if( defined( $fn = $location->[LOCATION_LOGICAL_FILE] ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | $fn =~ s/ (?= [\\"] ) /\\/smxg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | $content = qq{#line $location->[LOCATION_LOGICAL_LINE] "$fn"\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 12 | $content = qq{#line $location->[LOCATION_LOGICAL_LINE]\n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 13 | $content .= ' ' x ( $location->[LOCATION_COLUMN] - 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 34 | $content .= __normalize_interpolation_for_ppi( $self->content() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 34 | $self->{ppi} = PPI::Document->new( \$content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 34 | ▶ | if ( $location ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # Generate locations now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 13 | $self->{ppi}->location(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Remove the stuff we originally injected. NOTE that we can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # only get away with doing this if the removal does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # invalidate the locations of the other tokens that we just | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # generated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 13 | my $elem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # Remove the '#line' directive if we find it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 13 | ▶ | $elem = $self->{ppi}->child( 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Comment") and $elem->content =~ / \A \#line\b /msx
$elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Comment")
MC/DC0%0/3
$elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Comment") and $elem->content =~ / \A \#line\b /msx
$elem = $self->{"ppi"}->child(0)
$elem->isa("PPI::Token::Comment")
$elem->content =~ / \A \#line\b /msx
Truth table25%1/4
A and B and C
A= $elem = $self->{"ppi"}->child(0)B= $elem->isa("PPI::Token::Comment")C= $elem->content =~ / \A \#line\b /msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | and $elem->isa( 'PPI::Token::Comment' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | and $elem->content() =~ m/ \A \#line\b /smx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | and $elem->remove(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # Remove the white space if we find it, and if it in fact | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # represents only the white space we injected to get the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # column numbers right. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 13 | my $wid = $location->[LOCATION_COLUMN] - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $wid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 13 | ▶ | and $elem = $self->{ppi}->child( 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$wid and $elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Whitespace") and $wid == length $elem->content
$wid and $elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Whitespace")
$wid and $elem = $self->{"ppi"}->child(0)
MC/DC0%0/4
$wid and $elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Whitespace") and $wid == length $elem->content
$wid
$elem = $self->{"ppi"}->child(0)
$elem->isa("PPI::Token::Whitespace")
$wid == length $elem->content
Truth table20%1/5
A and B and C and D
A= $widB= $elem = $self->{"ppi"}->child(0)C= $elem->isa("PPI::Token::Whitespace")D= $wid == length $elem->content
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | and $elem->isa( 'PPI::Token::Whitespace' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | and $wid == length $elem->content() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | and $elem->remove(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 57 | return $self->{ppi}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 56 | ▶ | sub variables { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
variables: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 56 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 56 | return __variables( $self->ppi() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 16 | ▶ | sub __perl_version_introduced { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__perl_version_introduced: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 16 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | $self->{postderef} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 16 | ▶ | and return '5.019005'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||