lib/Perl/ToPerl6/Utils/PPI.pm

filter: Statementstmt 49.4% 125 / 253 Branchbran 28.1% 54 / 192 Conditioncond 18.6% 17 / 91 MC/DCmcdc 14.0% 7 / 50 Subroutinesub 53.4% 23 / 43 Podpod 15.1% 5 / 33 totaltotal 34.8% 231 / 662 CC 131 SCAR 33.4
CC
131
Cov
37%
is_ppi_constant_element
90.0
get_previous_module_used_on_same_line
90.0
get_constant_name_element_from_declaring_statement
72.0
CRAP 28.3
« lib/Perl/ToPerl6/Transformer/CompoundStatements/RewriteMapGreps.pm ↑ Summary lib/Perl/ToPerl6/Document.pm »
1 package Perl::ToPerl6::Utils::PPI;
2  
3 31 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 31 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 31 ▶use Scalar::Util qw< blessed readonly looks_like_number >;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 31 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #-----------------------------------------------------------------------------
14  
15 31 our @EXPORT_OK = qw(
16 dscanf
17  
18 is_ppi_expression_or_generic_statement
19 is_ppi_generic_statement
20 is_ppi_statement_subclass
21 is_ppi_simple_statement
22 is_ppi_constant_element
23  
24 is_package_boundary
25  
26 is_module_name
27 is_version_number
28 is_pragma
29  
30 is_ppi_token_word
31 is_ppi_token_operator
32 is_ppi_statement
33 is_ppi_statement_compound
34  
35 is_ppi_token_quotelike_words_like
36  
37 ppi_list_elements
38  
39 set_string
40  
41 make_ppi_structure_list
42 make_ppi_structure_block
43  
44 build_ppi_structure_block_from
45 build_ppi_structure_list_from
46  
47 remove_expression_remainder
48  
49 remove_trailing_whitespace
50 insert_trailing_whitespace
51  
52 remove_leading_whitespace
53 insert_leading_whitespace
54  
55 replace_remainder_with_block
56 replace_remainder_with_list
57 );
58  
59 31 our %EXPORT_TAGS = (
60 all => \@EXPORT_OK,
61 );
62  
63 #-----------------------------------------------------------------------------
64 #
65 # List the conversion possibilities separately, for now.
66 # I don't think there's much call for fancy modifiers, but I'll keep it in mind.
67  
68 31 my @conversions = sort { length($b) <=> length($a) } (
69 'd', 'bd', 'od', 'xd', # Decimals
70 'f', 'ef', 'ff', # Floating-point numbers
71 'o', # Operator
72 'r', 'mr', 'sr', 'tr', # Regular expressions
73 's', 'ds', 'ls', 'ss', 'is', # Strings
74 'v', 'av', 'gv', 'hv', 'sv', # Variables
75 'L', # List
76 'P', # Generic PPI token
77 'W', # Word
78 );
79 31 my $conversions_re = join '|', @conversions;
80 31 my %conversion_type = (
81 d => 'PPI::Token::Number',
82 bd => 'PPI::Token::Number::Binary',
83 od => 'PPI::Token::Number::Octal',
84 xd => 'PPI::Token::Number::Hex',
85 f => 'PPI::Token::Number::Float',
86 ef => 'PPI::Token::Number::Exp',
87 o => 'PPI::Token::Operator',
88 r => 'PPI::Token::Regexp',
89 mr => 'PPI::Token::Regexp::Match',
90 sr => 'PPI::Token::Regexp::Substitute',
91 tr => 'PPI::Token::Regexp::Transliterate',
92 s => 'PPI::Token::Quote::Single',
93 ds => 'PPI::Token::Quote::Double',
94 is => 'PPI::Token::Quote::Interpolate',
95 ls => 'PPI::Token::Quote::Literal',
96 ss => 'PPI::Token::Quote::Single',
97 v => 'PPI::Token::Symbol',
98 av => 'PPI::Token::Symbol', # Must be smarter later.
99 gv => 'PPI::Token::Symbol',
100 hv => 'PPI::Token::Symbol',
101 sv => 'PPI::Token::Symbol',
102 L => 'PPI::Structure::List',
103 W => 'PPI::Token::Word',
104 );
105  
106 161 ▶sub _retokenize {
Subroutine _retokenize: called CC=8 SCAR=23.4
107 161 my (@token) = @_;
108  
109 # Regroup the '%%', '%v' and modified conversions.
110 #
111 161 my @final_token;
112 161 ▶ for ( my $i = 0; $i < @token; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @token) 813 160 973
113 813 my $v = $token[$i];
114  
115 # If the token is a '%', then look ahead.
116 # If '%' is next, just tack it on to the existing '%' leaving '%%'.
117 # Otherwise, add whatever modifiers we can find from the next, and
118 # move on.
119 # Failing that, report that we've found a missing modifier.
120 #
121 813 ▶ if ( $v eq '%' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v eq '%') { } 319 494 813
122 319 ▶ if ( $token[$i+1] eq '%' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token[$i + 1] eq '%') { } 0 319 319
elsif ($token[$i + 1] =~ s/ ^ ($conversions_re) //x) { } 318 1 319
123 0 push @final_token, $v . $token[$i+1];
124 0 $i++;
125 }
126 elsif ( $token[$i+1] =~ s< ^ ($conversions_re) ><>x ) {
127 318 my $conversion = $1;
128 318 ▶ if ( $conversion eq 'P' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conversion eq "P") 0 318 318
129 0 $token[$i+1] =~ s< ^ \{ ([^\}]+) \} ><>x;
130 0 my $name = $1;
131 0 ▶ $name = 'PPI::' . $name unless $name =~ m< ^ PPI\:: >x;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ / ^ PPI\:: /x 0 0 0
132 0 $conversion .= $name;
133 }
134 318 push @final_token, $v . $conversion;
135 318 ▶ $i++ if $token[$i+1] eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $token[$i + 1] eq "" 318 0 318
136 }
137 else {
138 1 die "Unknown conversion '" . $token[$i+1] . "'";
139 }
140 }
141 else {
142 494 push @final_token, $v;
143 }
144 }
145 160 return @final_token;
146 }
147  
148 161 ▶sub dscanf {
Subroutine dscanf: called CC=9 SCAR=22.7
Pod documented
149 161 my ($format, $options) = @_;
150 161 my @token = grep { $_ ne '' } split / ( \s+ | \% ) /x, $format;
151 161 @token = _retokenize( @token );
152  
153 160 my @to_find;
154 160 for my $token ( @token ) {
155 808 ▶ next if $token =~ m< ^ \s+ $ >x;
Branch: 1 branch
BranchTrueFalseTotal
if $token =~ / ^ \s+ $ /x 324 484 808
156  
157 484 ▶ if ( $token eq '%%' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token eq '%%') { } 0 484 484
elsif ($token =~ s/ ^ \% //x) { } 318 166 484
158 0 push @to_find, {
159 type => 'PPI::Token::Operator',
160 content => '%'
161 };
162 }
163 elsif ( $token =~ s< ^ \% ><>x ) {
164 318 ▶ if ( exists $conversion_type{$token} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $conversion_type{$token}) { } 318 0 318
elsif ($token =~ s/ ^ P (.+) $ //x) { } 0 0 0
165 push @to_find, {
166 318 type => $conversion_type{$token}
167 };
168 }
169 elsif ( $token =~ s< ^ P (.+) $ ><>x ) {
170 0 push @to_find, {
171 type => $1
172 };
173 }
174 else {
175 0 die "Shouldn't happen, but a token type '$token' got here that we don't recognize, bailing.";
176 }
177 }
178 else {
179 166 ▶ if ( looks_like_number( $token ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (&looks_like_number($token)) { } 0 166 166
elsif ($token =~ / [^\w] /x) { } 3 163 166
180 0 push @to_find, {
181 type => 'PPI::Token::Number',
182 content => $token
183 };
184 }
185 elsif ( $token =~ / [^\w] /x ) {
186 3 push @to_find, {
187 type => 'PPI::Token::Operator',
188 content => $token
189 };
190 }
191 else {
192 163 push @to_find, {
193 type => 'PPI::Token::Word',
194 content => $token
195 };
196 }
197 }
198 }
199  
200 182 ▶ return sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
201 182 my $elem = $_[1];
202  
203 182 for my $match ( @to_find ) {
204 189 ▶ return 0 unless $elem->isa( $match->{type} );
Branch: 1 branch
BranchTrueFalseTotal
unless $elem->isa($match->{"type"}) 147 42 189
205 return 0 if $match->{content} and
206 42 ▶ $elem->content ne $match->{content};
Branch: 1 branch
BranchTrueFalseTotal
if $match->{"content"} and $elem->content ne $match->{"content"} 33 9 42
Condition100%3/3
$match->{"content"} and $elem->content ne $match->{"content"}
!ll&&!rl&&r
3633
MC/DC100%2/2
$match->{"content"} and $elem->content ne $match->{"content"}
$match->{"content"} $elem->content ne $match->{"content"}
Truth table100%3/3
A and B
A= $match->{"content"}B= $elem->content ne $match->{"content"}
ABresult
0X0
100
111
207 9 $elem = $elem->snext_sibling;
208 }
209 2 return 1;
210 160 };
211 }
212  
213 #-----------------------------------------------------------------------------
214  
215 476 ▶sub is_ppi_token_word {
Subroutine is_ppi_token_word: called CC=3 SCAR=11.0
Pod undocumented
216 476 my ($elem, %map) = @_;
217 $elem and
218 $elem->isa('PPI::Token::Word') and
219 476 ▶ exists $map{$elem->content};
Branch: 1 branch
BranchTrueFalseTotal
$elem and $elem->isa("PPI::Token::Word") and exists $map{$elem->content} 92 384 476
Condition100%3/3
$elem and $elem->isa("PPI::Token::Word")
!ll&&!rl&&r
138392
MC/DC100%2/2
$elem and $elem->isa("PPI::Token::Word")
$elem $elem->isa("PPI::Token::Word")
Truth table100%3/3
A and B
A= $elemB= $elem->isa("PPI::Token::Word")
ABresult
0X0
100
111
220 }
221  
222 #-----------------------------------------------------------------------------
223  
224 78 ▶sub is_ppi_token_operator {
Subroutine is_ppi_token_operator: called CC=3 SCAR=11.1
Pod undocumented
225 78 my ($elem, %map) = @_;
226 $elem and
227 $elem->isa('PPI::Token::Operator') and
228 78 ▶ exists $map{$elem->content};
Branch: 1 branch
BranchTrueFalseTotal
$elem and $elem->isa("PPI::Token::Operator") and exists $map{$elem->content} 2 76 78
Condition66%2/3
$elem and $elem->isa("PPI::Token::Operator")
!ll&&!rl&&r
0762
MC/DC50%1/2
$elem and $elem->isa("PPI::Token::Operator")
$elem $elem->isa("PPI::Token::Operator")
Truth table66%2/3
A and B
A= $elemB= $elem->isa("PPI::Token::Operator")
ABresult
0X0
100
111
229 }
230  
231 #-----------------------------------------------------------------------------
232  
233 0 ▶sub is_ppi_statement {
Subroutine is_ppi_statement: not called CC=3 SCAR=24.8
Pod undocumented
234 0 my ($elem, %map) = @_;
235 $elem and
236 $elem->isa('PPI::Statement') and
237 0 ▶ exists $map{$elem->first_element->content};
Branch: 1 branch
BranchTrueFalseTotal
$elem and $elem->isa("PPI::Statement") and exists $map{$elem->first_element->content} 0 0 0
Condition0%0/3
$elem and $elem->isa("PPI::Statement")
!ll&&!rl&&r
000
MC/DC0%0/2
$elem and $elem->isa("PPI::Statement")
$elem $elem->isa("PPI::Statement")
Truth table0%0/3
A and B
A= $elemB= $elem->isa("PPI::Statement")
ABresult
0X0
100
111
238 }
239  
240 #-----------------------------------------------------------------------------
241  
242 246 ▶sub is_ppi_statement_compound {
Subroutine is_ppi_statement_compound: called CC=3 SCAR=13.1
Pod undocumented
243 246 my ($elem, %map) = @_;
244 $elem and
245 $elem->isa('PPI::Statement::Compound') and
246 246 ▶ exists $map{$elem->first_element->content};
Branch: 1 branch
BranchTrueFalseTotal
$elem and $elem->isa("PPI::Statement::Compound") and exists $map{$elem->first_element->content} 0 246 246
Condition33%1/3
$elem and $elem->isa("PPI::Statement::Compound")
!ll&&!rl&&r
02460
MC/DC0%0/2
$elem and $elem->isa("PPI::Statement::Compound")
$elem $elem->isa("PPI::Statement::Compound")
Truth table33%1/3
A and B
A= $elemB= $elem->isa("PPI::Statement::Compound")
ABresult
0X0
100
111
247 }
248  
249 #-----------------------------------------------------------------------------
250  
251 32 ▶sub is_ppi_token_quotelike_words_like {
Subroutine is_ppi_token_quotelike_words_like: called CC=3 SCAR=13.1
Pod undocumented
252 32 my ($elem, $qr) = @_;
253 32 ▶ $elem and
Branch: 1 branch
BranchTrueFalseTotal
$elem and $elem->isa("PPI::Token::QuoteLike::Words") and $elem->content =~ /$qr/ 0 32 32
Condition33%1/3
$elem and $elem->isa("PPI::Token::QuoteLike::Words")
!ll&&!rl&&r
0320
MC/DC0%0/2
$elem and $elem->isa("PPI::Token::QuoteLike::Words")
$elem $elem->isa("PPI::Token::QuoteLike::Words")
Truth table33%1/3
A and B
A= $elemB= $elem->isa("PPI::Token::QuoteLike::Words")
ABresult
0X0
100
111
254 $elem->isa('PPI::Token::QuoteLike::Words') and
255 $elem->content =~ $qr
256 }
257  
258 #-----------------------------------------------------------------------------
259  
260 0 ▶sub _ppi_list_elements {
Subroutine _ppi_list_elements: not called CC=5 SCAR=34.0
261 0 my ($elem) = @_;
262 0 my @elements;
263 0 for my $_elem ( $elem->schildren ) {
264 0 ▶ if ( $_elem->isa('PPI::Token::Quote') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_elem->isa('PPI::Token::Quote')) { } 0 0 0
elsif ($_elem->isa('PPI::Structure::List') and $_elem->schildren) { } 0 0 0
265 0 push @elements, $_elem->string;
266 }
267 ▶ elsif ( $_elem->isa('PPI::Structure::List') and
Condition0%0/3
$_elem->isa("PPI::Structure::List") and $_elem->schildren
!ll&&!rl&&r
000
MC/DC0%0/2
$_elem->isa("PPI::Structure::List") and $_elem->schildren
$_elem->isa("PPI::Structure::List") $_elem->schildren
Truth table0%0/3
A and B
A= $_elem->isa("PPI::Structure::List")B= $_elem->schildren
ABresult
0X0
100
111
268 $_elem->schildren ) {
269 0 push @elements, _ppi_list_elements($_elem->schild(0));
270 }
271 }
272 0 return @elements;
273 }
274  
275 0 ▶sub ppi_list_elements {
Subroutine ppi_list_elements: not called CC=5 SCAR=34.0
Pod undocumented
276 0 my ($elem) = @_;
277 0 ▶ return $elem->literal if $elem->isa('PPI::Token::QuoteLike::Words');
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Token::QuoteLike::Words") 0 0 0
278  
279 0 ▶ if ( $elem->isa('PPI::Structure::List') and
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Structure::List") and $elem->schild(0) and $elem->schild(0)->isa("PPI::Statement::Expression")) 0 0 0
Condition0%0/6
$elem->isa("PPI::Structure::List") and $elem->schild(0) and $elem->schild(0)->isa("PPI::Statement::Expression")
!ll&&!rl&&r
000
$elem->isa("PPI::Structure::List") and $elem->schild(0)
!ll&&!rl&&r
000
MC/DC0%0/3
$elem->isa("PPI::Structure::List") and $elem->schild(0) and $elem->schild(0)->isa("PPI::Statement::Expression")
$elem->isa("PPI::Structure::List") $elem->schild(0) $elem->schild(0)->isa("PPI::Statement::Expression")
Truth table0%0/4
A and B and C
A= $elem->isa("PPI::Structure::List")B= $elem->schild(0)C= $elem->schild(0)->isa("PPI::Statement::Expression")
ABCresult
0XX0
10X0
1100
1111
280 $elem->schild(0) and
281 $elem->schild(0)->isa('PPI::Statement::Expression') ) {
282 0 return _ppi_list_elements($elem->schild(0));
283 }
284 }
285  
286 #-----------------------------------------------------------------------------
287  
288 1 ▶sub is_module_name {
Subroutine is_module_name: called CC=5 SCAR=17.0
Pod undocumented
289 1 my $element = shift;
290  
291 1 ▶ return if not $element;
Branch: 1 branch
BranchTrueFalseTotal
unless $element 0 1 1
292  
293 1 ▶ return unless $element->isa('PPI::Token::Word');
Branch: 1 branch
BranchTrueFalseTotal
unless $element->isa("PPI::Token::Word") 0 1 1
294 1 my $content = $element->content;
295  
296 1 ▶ return if looks_like_number($content);
Branch: 1 branch
BranchTrueFalseTotal
if &looks_like_number($content) 0 1 1
297 1 ▶ return if $content =~ /^v\d+/;
Branch: 1 branch
BranchTrueFalseTotal
if $content =~ /^v\d+/ 0 1 1
298  
299 1 return 1;
300 }
301  
302 #-----------------------------------------------------------------------------
303  
304 1 ▶sub is_version_number {
Subroutine is_version_number: called CC=7 SCAR=22.7
Pod undocumented
305 1 my $element = shift;
306  
307 1 ▶ return if not $element;
Branch: 1 branch
BranchTrueFalseTotal
unless $element 0 1 1
308  
309 1 ▶ return unless $element->isa('PPI::Token::Word') or
Branch: 1 branch
BranchTrueFalseTotal
unless $element->isa("PPI::Token::Word") or $element->isa("PPI::Token::Number::Version") or $element->isa("PPI::Token::Number::Float") 0 1 1
Condition33%2/6
$element->isa("PPI::Token::Word") or $element->isa("PPI::Token::Number::Version") or $element->isa("PPI::Token::Number::Float")
l!l&&r!l&&!r
100
$element->isa("PPI::Token::Word") or $element->isa("PPI::Token::Number::Version")
l!l&&r!l&&!r
100
MC/DC0%0/3
$element->isa("PPI::Token::Word") or $element->isa("PPI::Token::Number::Version") or $element->isa("PPI::Token::Number::Float")
$element->isa("PPI::Token::Word") $element->isa("PPI::Token::Number::Version") $element->isa("PPI::Token::Number::Float")
Truth table25%1/4
A or B or C
A= $element->isa("PPI::Token::Word")B= $element->isa("PPI::Token::Number::Version")C= $element->isa("PPI::Token::Number::Float")
ABCresult
1XX1
01X1
0011
0000
310 $element->isa('PPI::Token::Number::Version') or
311 $element->isa('PPI::Token::Number::Float');
312 1 my $content = $element->content;
313  
314 1 ▶ return 1 if looks_like_number($content);
Branch: 1 branch
BranchTrueFalseTotal
if &looks_like_number($content) 0 1 1
315 1 ▶ return 1 if $content =~ /^v\d+/;
Branch: 1 branch
BranchTrueFalseTotal
if $content =~ /^v\d+/ 0 1 1
316  
317 1 return;
318 }
319  
320 #-----------------------------------------------------------------------------
321  
322 2 ▶sub is_pragma {
Subroutine is_pragma: called CC=4 SCAR=14.3
Pod undocumented
323 2 my $element = shift;
324  
325 2 ▶ return if not $element;
Branch: 1 branch
BranchTrueFalseTotal
unless $element 0 2 2
326  
327 2 ▶ return unless $element->isa('PPI::Token::Word');
Branch: 1 branch
BranchTrueFalseTotal
unless $element->isa("PPI::Token::Word") 0 2 2
328 2 my $content = $element->content;
329  
330 2 my %pragma = (
331 strict => 1,
332 warnings => 1,
333 autodie => 1,
334 base => 1,
335 parent => 1,
336 bigint => 1,
337 bignum => 1,
338 bigrat => 1,
339 constant => 1,
340 mro => 1,
341 encoding => 1,
342 integer => 1,
343 lib => 1,
344 mro => 1,
345 utf8 => 1,
346 vars => 1,
347 );
348  
349 2 ▶ return 1 if exists $pragma{$content};
Branch: 1 branch
BranchTrueFalseTotal
if exists $pragma{$content} 0 2 2
350  
351 2 return;
352 }
353  
354 #-----------------------------------------------------------------------------
355  
356 0 ▶sub set_string {
Subroutine set_string: not called CC=7 SCAR=40.3
Pod undocumented
357 0 my ($elem, $string) = @_;
358 0 ▶ $string = '' unless $string;
Branch: 1 branch
BranchTrueFalseTotal
unless $string 0 0 0
359  
360 0 my $content = $elem->content;
361 0 ▶ if ($content =~ m/ ^ ['"] /x ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($content =~ / ^ ['"] /x) { } 0 0 0
elsif ($content =~ /^qq ./) { } 0 0 0
elsif ($content =~ /^qq./) { } 0 0 0
elsif ($content =~ /^q ./) { } 0 0 0
elsif ($content =~ /^q./) { } 0 0 0
362 0 substr($content, 1, -1) = $string;
363 }
364 elsif ($content =~ m/^qq ./ ) {
365 0 substr($content, 4, -1) = $string;
366 }
367 elsif ($content =~ m/^qq./ ) {
368 0 substr($content, 3, -1) = $string;
369 }
370 elsif ($content =~ m/^q ./ ) {
371 0 substr($content, 3, -1) = $string;
372 }
373 elsif ($content =~ m/^q./ ) {
374 0 substr($content, 2, -1) = $string;
375 }
376 else {
377 0 die "Unknown string delimiters! >$content<\n";
378 }
379 0 $elem->set_content( $content );
380 }
381  
382 #-----------------------------------------------------------------------------
383  
384 0 ▶sub make_ppi_structure_block {
Subroutine make_ppi_structure_block: not called CC=1 SCAR=6.9
Pod undocumented
385 0 my $new_list = PPI::Structure::Block->new(
386 PPI::Token::Structure->new('{'),
387 );
388 0 $new_list->{finish} = PPI::Token::Structure->new('}');
389  
390 0 return $new_list;
391 }
392  
393 #-----------------------------------------------------------------------------
394  
395 4 ▶sub make_ppi_structure_list {
Subroutine make_ppi_structure_list: called CC=1 SCAR=0.0
Pod undocumented
396 4 my $new_list = PPI::Structure::List->new(
397 PPI::Token::Structure->new('('),
398 );
399 4 $new_list->{finish} = PPI::Token::Structure->new(')');
400  
401 4 return $new_list;
402 }
403  
404 #-----------------------------------------------------------------------------
405  
406 0 ▶sub build_ppi_structure_block_from {
Subroutine build_ppi_structure_block_from: not called CC=4 SCAR=30.0
Pod undocumented
407 0 my ($head, $terminator_test) = @_;
408  
409 0 my $new_block = make_ppi_structure_block;
410 0 my $new_statement = PPI::Statement->new;
411  
412 0 ▶ while ( $head and $head->next_sibling ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head and $head->next_sibling) 0 0 0
Condition0%0/3
$head and $head->next_sibling
!ll&&!rl&&r
000
MC/DC0%0/2
$head and $head->next_sibling
$head $head->next_sibling
Truth table0%0/3
A and B
A= $headB= $head->next_sibling
ABresult
0X0
100
111
413 0 ▶ last if $terminator_test->(undef,$head);
Branch: 1 branch
BranchTrueFalseTotal
if &$terminator_test(undef, $head) 0 0 0
414  
415 0 $new_statement->add_element($head->clone);
416 0 $head = $head->next_sibling;
417 }
418  
419 0 $new_block->add_element($new_statement);
420 0 return $new_block;
421 }
422  
423 #-----------------------------------------------------------------------------
424  
425 4 ▶sub build_ppi_structure_list_from {
Subroutine build_ppi_structure_list_from: called CC=4 SCAR=13.9
Pod undocumented
426 4 my ($head, $terminator_test) = @_;
427  
428 4 my $new_list = make_ppi_structure_list;
429 4 my $new_statement = PPI::Statement->new;
430  
431 4 ▶ while ( $head and $head->next_sibling ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head and $head->next_sibling) 1 4 5
Condition66%2/3
$head and $head->next_sibling
!ll&&!rl&&r
041
MC/DC50%1/2
$head and $head->next_sibling
$head $head->next_sibling
Truth table66%2/3
A and B
A= $headB= $head->next_sibling
ABresult
0X0
100
111
432 1 ▶ last if $terminator_test->(undef,$head);
Branch: 1 branch
BranchTrueFalseTotal
if &$terminator_test(undef, $head) 0 1 1
433  
434 1 $new_statement->add_element($head->clone);
435 1 $head = $head->next_sibling;
436 }
437  
438 4 $new_list->add_element($new_statement);
439 4 return $new_list;
440 }
441  
442 #-----------------------------------------------------------------------------
443  
444 4 ▶sub remove_expression_remainder {
Subroutine remove_expression_remainder: called CC=3 SCAR=11.0
Pod undocumented
445 4 my ($head, $callback) = @_;
446 4 ▶ while ( $head and not $callback->(undef,$head) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head and not &$callback(undef, $head)) 1 4 5
Condition66%2/3
$head and not &$callback(undef, $head)
!ll&&!rl&&r
041
MC/DC50%1/2
$head and not &$callback(undef, $head)
$head not &$callback(undef, $head)
Truth table66%2/3
A and not(B)
A= $headB= not &$callback(undef, $head)
ABresult
0X0
100
111
447 1 my $temp = $head->next_sibling;
448 1 $head->remove;
449 1 $head = $temp;
450 }
451 }
452  
453 #-----------------------------------------------------------------------------
454  
455 8 ▶sub remove_trailing_whitespace {
Subroutine remove_trailing_whitespace: called CC=3 SCAR=11.0
Pod undocumented
456 8 my ($head) = @_;
457 8 ▶ return unless $head->next_sibling;
Branch: 1 branch
BranchTrueFalseTotal
unless $head->next_sibling 0 8 8
458 8 ▶ return unless $head->next_sibling->isa('PPI::Token::Whitespace');
Branch: 1 branch
BranchTrueFalseTotal
unless $head->next_sibling->isa("PPI::Token::Whitespace") 4 4 8
459 4 my $white = $head->next_sibling->clone;
460 4 $head->next_sibling->remove;
461 4 return $white;
462 }
463  
464 #-----------------------------------------------------------------------------
465  
466 4 ▶sub insert_trailing_whitespace {
Subroutine insert_trailing_whitespace: called CC=4 SCAR=17.1
Pod undocumented
467 4 my ($head, $optional_whitespace) = @_;
468 4 ▶ $optional_whitespace = ' ' unless defined $optional_whitespace;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $optional_whitespace 4 0 4
469 4 ▶ return if $head->next_sibling and
Branch: 1 branch
BranchTrueFalseTotal
if $head->next_sibling and $head->next_sibling->isa("PPI::Token::Whitespace") 4 0 4
Condition33%1/3
$head->next_sibling and $head->next_sibling->isa("PPI::Token::Whitespace")
!ll&&!rl&&r
004
MC/DC0%0/2
$head->next_sibling and $head->next_sibling->isa("PPI::Token::Whitespace")
$head->next_sibling $head->next_sibling->isa("PPI::Token::Whitespace")
Truth table33%1/3
A and B
A= $head->next_siblingB= $head->next_sibling->isa("PPI::Token::Whitespace")
ABresult
0X0
100
111
470 $head->next_sibling->isa('PPI::Token::Whitespace');
471 0 $head->insert_after(
472 PPI::Token::Whitespace->new($optional_whitespace)
473 );
474 }
475  
476 #-----------------------------------------------------------------------------
477  
478 0 ▶sub remove_leading_whitespace {
Subroutine remove_leading_whitespace: not called CC=3 SCAR=24.8
Pod undocumented
479 0 my ($head) = @_;
480 0 ▶ return unless $head->previous_sibling;
Branch: 1 branch
BranchTrueFalseTotal
unless $head->previous_sibling 0 0 0
481 0 ▶ return unless $head->previous_sibling->isa('PPI::Token::Whitespace');
Branch: 1 branch
BranchTrueFalseTotal
unless $head->previous_sibling->isa("PPI::Token::Whitespace") 0 0 0
482 0 my $white = $head->previous_sibling->clone;
483 0 $head->previous_sibling->remove;
484 0 return $white;
485 }
486  
487 #-----------------------------------------------------------------------------
488  
489 0 ▶sub insert_leading_whitespace {
Subroutine insert_leading_whitespace: not called CC=4 SCAR=30.0
Pod undocumented
490 0 my ($head, $optional_whitespace) = @_;
491 0 ▶ $optional_whitespace = ' ' unless defined $optional_whitespace;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $optional_whitespace 0 0 0
492 0 ▶ return if $head->previous_sibling and
Branch: 1 branch
BranchTrueFalseTotal
if $head->previous_sibling and $head->previous_sibling->isa("PPI::Token::Whitespace") 0 0 0
Condition0%0/3
$head->previous_sibling and $head->previous_sibling->isa("PPI::Token::Whitespace")
!ll&&!rl&&r
000
MC/DC0%0/2
$head->previous_sibling and $head->previous_sibling->isa("PPI::Token::Whitespace")
$head->previous_sibling $head->previous_sibling->isa("PPI::Token::Whitespace")
Truth table0%0/3
A and B
A= $head->previous_siblingB= $head->previous_sibling->isa("PPI::Token::Whitespace")
ABresult
0X0
100
111
493 $head->previous_sibling->isa('PPI::Token::Whitespace');
494 0 $head->insert_before(
495 PPI::Token::Whitespace->new($optional_whitespace)
496 );
497 }
498 #-----------------------------------------------------------------------------
499  
500 0 ▶sub replace_remainder_with_block {
Subroutine replace_remainder_with_block: not called CC=1 SCAR=6.9
Pod undocumented
501 0 my ($head, $callback) = @_;
502 0 my $new_block = build_ppi_structure_block_from( $head, $callback );
503  
504 0 $head->insert_before($new_block);
505 0 remove_expression_remainder( $head, $callback );
506 }
507  
508 #-----------------------------------------------------------------------------
509  
510 4 ▶sub replace_remainder_with_list {
Subroutine replace_remainder_with_list: called CC=1 SCAR=0.0
Pod undocumented
511 4 my ($head, $callback) = @_;
512 4 my $new_list = build_ppi_structure_list_from( $head, $callback );
513  
514 4 $head->insert_before($new_list);
515 4 remove_expression_remainder( $head, $callback );
516 }
517  
518 #-----------------------------------------------------------------------------
519  
520 0 ▶sub is_ppi_generic_statement {
Subroutine is_ppi_generic_statement: not called CC=3 SCAR=24.8
Pod documented
521 0 my $element = shift;
522  
523 0 my $element_class = blessed($element);
524  
525 0 ▶ return if not $element_class;
Branch: 1 branch
BranchTrueFalseTotal
unless $element_class 0 0 0
526 0 ▶ return if not $element->isa('PPI::Statement');
Branch: 1 branch
BranchTrueFalseTotal
unless $element->isa("PPI::Statement") 0 0 0
527  
528 0 return $element_class eq 'PPI::Statement';
529 }
530  
531 #-----------------------------------------------------------------------------
532  
533 0 ▶sub is_ppi_statement_subclass {
Subroutine is_ppi_statement_subclass: not called CC=3 SCAR=24.8
Pod documented
534 0 my $element = shift;
535  
536 0 my $element_class = blessed($element);
537  
538 0 ▶ return if not $element_class;
Branch: 1 branch
BranchTrueFalseTotal
unless $element_class 0 0 0
539 0 ▶ return if not $element->isa('PPI::Statement');
Branch: 1 branch
BranchTrueFalseTotal
unless $element->isa("PPI::Statement") 0 0 0
540  
541 0 return $element_class ne 'PPI::Statement';
542 }
543  
544 #-----------------------------------------------------------------------------
545  
546 # Can not use hashify() here because Perl::Critic::Utils already depends on
547 # this module.
548 31 Readonly::Hash my %SIMPLE_STATEMENT_CLASS => map { $_ => 1 } qw<
549 PPI::Statement
550 PPI::Statement::Break
551 PPI::Statement::Include
552 PPI::Statement::Null
553 PPI::Statement::Package
554 PPI::Statement::Variable
555 >;
556  
557 0 ▶sub is_ppi_simple_statement {
Subroutine is_ppi_simple_statement: not called CC=3 SCAR=24.8
Pod documented
558 0 ▶ my $element = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $element = shift() or return 0 0 0
559  
560 0 ▶ my $element_class = blessed( $element ) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $element_class = builtin::blessed($element) or return 0 0 0
561  
562 0 return $SIMPLE_STATEMENT_CLASS{ $element_class };
563 }
564  
565 #-----------------------------------------------------------------------------
566  
567 0 ▶sub is_ppi_constant_element {
Subroutine is_ppi_constant_element: not called CC=9 SCAR=45.0
Pod undocumented
568 0 ▶ my $element = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $element = shift() or return 0 0 0
569  
570 0 ▶ blessed( $element ) or return;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($element) or return 0 0 0
571  
572 # TODO implement here documents once PPI::Token::HereDoc grows the
573 # necessary PPI::Token::Quote interface.
574 return
575 0 ▶ $element->isa( 'PPI::Token::Number' )
Condition0%0/18
$element->isa('PPI::Token::Number') || $element->isa('PPI::Token::Quote::Literal') || $element->isa('PPI::Token::Quote::Single') || $element->isa('PPI::Token::QuoteLike::Words') || ($element->isa('PPI::Token::Quote::Double') || $element->isa('PPI::Token::Quote::Interpolate')) && !($element->string =~ / (?: \A | [^\\] ) (?: \\\\)* [\$\@] /msx)
l!l&&r!l&&!r
000
$element->isa("PPI::Token::Number") or $element->isa("PPI::Token::Quote::Literal") or $element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::QuoteLike::Words")
l!l&&r!l&&!r
000
$element->isa("PPI::Token::Number") or $element->isa("PPI::Token::Quote::Literal") or $element->isa("PPI::Token::Quote::Single")
l!l&&r!l&&!r
000
$element->isa("PPI::Token::Number") or $element->isa("PPI::Token::Quote::Literal")
l!l&&r!l&&!r
000
$element->isa("PPI::Token::Quote::Double") || $element->isa("PPI::Token::Quote::Interpolate") and not $element->string =~ / (?: \A | [^\\] ) (?: \\\\)* [\$\@] /msx
!ll&&!rl&&r
000
$element->isa("PPI::Token::Quote::Double") or $element->isa("PPI::Token::Quote::Interpolate")
l!l&&r!l&&!r
000
MC/DC0%0/7
$element->isa('PPI::Token::Number') || $element->isa('PPI::Token::Quote::Literal') || $element->isa('PPI::Token::Quote::Single') || $element->isa('PPI::Token::QuoteLike::Words') || ($element->isa('PPI::Token::Quote::Double') || $element->isa('PPI::Token::Quote::Interpolate')) && !($element->string =~ / (?: \A | [^\\] ) (?: \\\\)* [\$\@] /msx)
$element->isa("PPI::Token::Number") $element->isa("PPI::Token::Quote::Literal") $element->isa("PPI::Token::Quote::Single") $element->isa("PPI::Token::QuoteLike::Words") $element->isa("PPI::Token::Quote::Double") $element->isa("PPI::Token::Quote::Interpolate") not $element->string =~ / (?: \A | [^\\] ) (?: \\\\)* [\$\@] /msx
Truth table0%0/9
A or B or C or D || E or F and not(G)
A= $element->isa("PPI::Token::Number")B= $element->isa("PPI::Token::Quote::Literal")C= $element->isa("PPI::Token::Quote::Single")D= $element->isa("PPI::Token::QuoteLike::Words")E= $element->isa("PPI::Token::Quote::Double")F= $element->isa("PPI::Token::Quote::Interpolate")G= not $element->string =~ / (?: \A | [^\\] ) (?: \\\\)* [\$\@] /msx
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001X11
00000111
000000X0
00001X00
00000100
576 || $element->isa( 'PPI::Token::Quote::Literal' )
577 || $element->isa( 'PPI::Token::Quote::Single' )
578 || $element->isa( 'PPI::Token::QuoteLike::Words' )
579 || (
580 $element->isa( 'PPI::Token::Quote::Double' )
581 || $element->isa( 'PPI::Token::Quote::Interpolate' ) )
582 && $element->string() !~ m< (?: \A | [^\\] ) (?: \\\\)* [\$\@] >smx
583 ;
584 }
585  
586 #-----------------------------------------------------------------------------
587  
588 0 ▶sub is_package_boundary {
Subroutine is_package_boundary: not called CC=6 SCAR=37.4
Pod undocumented
589 0 my ($elem) = @_;
590 0 ▶ return unless $elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 0 0
591 0 ▶ return 1 if $elem->isa('PPI::Statement::Package');
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Statement::Package") 0 0 0
592 0 ▶ return 1 if $elem->isa('PPI::Statement::End');
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Statement::End") 0 0 0
593 0 ▶ return 1 if $elem->isa('PPI::Statement::Data');
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Statement::Data") 0 0 0
594 0 ▶ return 1 if $elem->isa('PPI::Token::Separator');
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Token::Separator") 0 0 0
595 0 return;
596 }
597  
598 #-----------------------------------------------------------------------------
599  
600 0 ▶sub is_subroutine_declaration {
Subroutine is_subroutine_declaration: not called CC=7 SCAR=40.3
Pod undocumented
601 0 my $element = shift;
602  
603 0 ▶ return if not $element;
Branch: 1 branch
BranchTrueFalseTotal
unless $element 0 0 0
604  
605 0 ▶ return 1 if $element->isa('PPI::Statement::Sub');
Branch: 1 branch
BranchTrueFalseTotal
if $element->isa("PPI::Statement::Sub") 0 0 0
606  
607 0 ▶ if ( is_ppi_generic_statement($element) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_ppi_generic_statement($element)) 0 0 0
608 0 my $first_element = $element->first_element();
609  
610 0 ▶ return 1 if
Branch: 1 branch
BranchTrueFalseTotal
if $first_element and $first_element->isa("PPI::Token::Word") and $first_element->content eq "sub" 0 0 0
Condition0%0/6
$first_element and $first_element->isa("PPI::Token::Word") and $first_element->content eq "sub"
!ll&&!rl&&r
000
$first_element and $first_element->isa("PPI::Token::Word")
!ll&&!rl&&r
000
MC/DC0%0/3
$first_element and $first_element->isa("PPI::Token::Word") and $first_element->content eq "sub"
$first_element $first_element->isa("PPI::Token::Word") $first_element->content eq "sub"
Truth table0%0/4
A and B and C
A= $first_elementB= $first_element->isa("PPI::Token::Word")C= $first_element->content eq "sub"
ABCresult
0XX0
10X0
1100
1111
611 $first_element
612 and $first_element->isa('PPI::Token::Word')
613 and $first_element->content() eq 'sub';
614 }
615  
616 0 return;
617 }
618  
619 #-----------------------------------------------------------------------------
620  
621 0 ▶sub is_in_subroutine {
Subroutine is_in_subroutine: not called CC=5 SCAR=34.0
Pod undocumented
622 0 my ($element) = @_;
623  
624 0 ▶ return if not $element;
Branch: 1 branch
BranchTrueFalseTotal
unless $element 0 0 0
625 0 ▶ return 1 if is_subroutine_declaration($element);
Branch: 1 branch
BranchTrueFalseTotal
if is_subroutine_declaration($element) 0 0 0
626  
627 0 ▶ while ( $element = $element->parent() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element = $element->parent) 0 0 0
628 0 ▶ return 1 if is_subroutine_declaration($element);
Branch: 1 branch
BranchTrueFalseTotal
if is_subroutine_declaration($element) 0 0 0
629 }
630  
631 0 return;
632 }
633  
634 #-----------------------------------------------------------------------------
635  
636 0 ▶sub get_constant_name_element_from_declaring_statement {
Subroutine get_constant_name_element_from_declaring_statement: not called CC=8 SCAR=42.8
Pod undocumented
637 0 my ($element) = @_;
638  
639 0 warnings::warnif(
640 'deprecated',
641 'Perl::Critic::Utils::PPI::get_constant_name_element_from_declaring_statement() is deprecated. Use PPIx::Utilities::Statement::get_constant_name_elements_from_declaring_statement() instead.',
642 );
643  
644 0 ▶ return if not $element;
Branch: 1 branch
BranchTrueFalseTotal
unless $element 0 0 0
645 0 ▶ return if not $element->isa('PPI::Statement');
Branch: 1 branch
BranchTrueFalseTotal
unless $element->isa("PPI::Statement") 0 0 0
646  
647 0 ▶ if ( $element->isa('PPI::Statement::Include') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($element->isa('PPI::Statement::Include')) { } 0 0 0
elsif (is_ppi_generic_statement($element) and $element->schild(0)->content =~ / \A Readonly \b /msx) { } 0 0 0
648 0 my $pragma;
649 0 ▶ if ( $pragma = $element->pragma() and $pragma eq 'constant' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pragma = $element->pragma and $pragma eq "constant") 0 0 0
Condition0%0/3
$pragma = $element->pragma and $pragma eq "constant"
!ll&&!rl&&r
000
MC/DC0%0/2
$pragma = $element->pragma and $pragma eq "constant"
$pragma = $element->pragma $pragma eq "constant"
Truth table0%0/3
A and B
A= $pragma = $element->pragmaB= $pragma eq "constant"
ABresult
0X0
100
111
650 0 return _constant_name_from_constant_pragma($element);
651 }
652 }
653 ▶ elsif (
Condition0%0/3
is_ppi_generic_statement($element) and $element->schild(0)->content =~ / \A Readonly \b /msx
!ll&&!rl&&r
000
MC/DC0%0/2
is_ppi_generic_statement($element) and $element->schild(0)->content =~ / \A Readonly \b /msx
is_ppi_generic_statement($element) $element->schild(0)->content =~ / \A Readonly \b /msx
Truth table0%0/3
A and B
A= is_ppi_generic_statement($element)B= $element->schild(0)->content =~ / \A Readonly \b /msx
ABresult
0X0
100
111
654 is_ppi_generic_statement($element)
655 and $element->schild(0)->content() =~ m< \A Readonly \b >xms
656 ) {
657 0 return $element->schild(2);
658 }
659  
660 0 return;
661 }
662  
663 0 ▶sub _constant_name_from_constant_pragma {
Subroutine _constant_name_from_constant_pragma: not called CC=3 SCAR=24.8
664 0 my ($include) = @_;
665  
666 0 ▶ my @arguments = $include->arguments() or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@arguments) = $include->arguments or return 0 0 0
667  
668 0 my $follower = $arguments[0];
669 0 ▶ return if not defined $follower;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $follower 0 0 0
670  
671 0 return $follower;
672 }
673  
674 #-----------------------------------------------------------------------------
675  
676 0 ▶sub get_next_element_in_same_simple_statement {
Subroutine get_next_element_in_same_simple_statement: not called CC=7 SCAR=40.3
Pod undocumented
677 0 ▶ my $element = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $element = shift() or return 0 0 0
678  
679 0 ▶ while ( $element and (
Branch: 1 branch
BranchTrueFalseTotal
if ($element and !is_ppi_simple_statement($element) || $element->parent && $element->parent->isa("PPI::Structure::List")) 0 0 0
Condition0%0/9
$element and !is_ppi_simple_statement($element) || $element->parent && $element->parent->isa("PPI::Structure::List")
!ll&&!rl&&r
000
not is_ppi_simple_statement($element) or $element->parent and $element->parent->isa("PPI::Structure::List")
l!l&&r!l&&!r
000
$element->parent and $element->parent->isa("PPI::Structure::List")
!ll&&!rl&&r
000
MC/DC0%0/4
$element and !is_ppi_simple_statement($element) || $element->parent && $element->parent->isa("PPI::Structure::List")
$element not is_ppi_simple_statement($element) $element->parent $element->parent->isa("PPI::Structure::List")
Truth table0%0/5
A and not(B) or C and D
A= $elementB= not is_ppi_simple_statement($element)C= $element->parentD= $element->parent->isa("PPI::Structure::List")
ABCDresult
0XXX0
100X0
10100
11XX1
10111
680 not is_ppi_simple_statement( $element )
681 or $element->parent()
682 and $element->parent()->isa( 'PPI::Structure::List' ) ) ) {
683 0 my $next;
684 0 ▶ $next = $element->snext_sibling() and return $next;
Branch: 1 branch
BranchTrueFalseTotal
$next = $element->snext_sibling and return $next 0 0 0
685 0 $element = $element->parent();
686 }
687 0 return;
688  
689 }
690  
691 #-----------------------------------------------------------------------------
692  
693 0 ▶sub get_previous_module_used_on_same_line {
Subroutine get_previous_module_used_on_same_line: not called CC=9 SCAR=45.0
Pod undocumented
694 0 ▶ my $element = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $element = shift() or return 0 0 0
695  
696 0 ▶ my ( $line ) = @{ $element->location() || []};
Condition0%0/2
$element->location || []
l!l
00
MC/DC0%0/1
$element->location || []
$element->location
Truth table0%0/2
A
A= $element->location
Aresult
11
00
697  
698 0 ▶ while (not is_ppi_simple_statement( $element )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_ppi_simple_statement($element)) 0 0 0
699 0 ▶ $element = $element->parent() or return;
Branch: 1 branch
BranchTrueFalseTotal
$element = $element->parent or return 0 0 0
700 }
701  
702 0 ▶ while ( $element = $element->sprevious_sibling() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element = $element->sprevious_sibling) 0 0 0
703 0 ▶ ( @{ $element->location() || []} )[0] == $line or return;
Branch: 1 branch
BranchTrueFalseTotal
(@{$element->location or [];})[0] == $line or return 0 0 0
Condition0%0/2
$element->location || []
l!l
00
MC/DC0%0/1
$element->location || []
$element->location
Truth table0%0/2
A
A= $element->location
Aresult
11
00
704 0 ▶ $element->isa( 'PPI::Statement::Include' )
Branch: 1 branch
BranchTrueFalseTotal
$element->isa("PPI::Statement::Include") and return $element->schild(1) 0 0 0
705 and return $element->schild( 1 );
706 }
707  
708 0 return;
709 }
710  
711 #-----------------------------------------------------------------------------
712  
713 3 ▶sub is_ppi_expression_or_generic_statement {
Subroutine is_ppi_expression_or_generic_statement: called CC=5 SCAR=16.5
Pod documented
714 3 my $element = shift;
715  
716 3 ▶ return if not $element;
Branch: 1 branch
BranchTrueFalseTotal
unless $element 0 3 3
717 3 ▶ return if not $element->isa('PPI::Statement');
Branch: 1 branch
BranchTrueFalseTotal
unless $element->isa("PPI::Statement") 0 3 3
718 3 ▶ return 1 if $element->isa('PPI::Statement::Expression');
Branch: 1 branch
BranchTrueFalseTotal
if $element->isa("PPI::Statement::Expression") 1 2 3
719  
720 2 my $element_class = blessed($element);
721  
722 2 ▶ return if not $element_class;
Branch: 1 branch
BranchTrueFalseTotal
unless $element_class 0 2 2
723 2 return $element_class eq 'PPI::Statement';
724 }
725 #-----------------------------------------------------------------------------
726  
727 31 1;
728  
729 __END__
« lib/Perl/ToPerl6/Transformer/CompoundStatements/RewriteMapGreps.pm ↑ Summary lib/Perl/ToPerl6/Document.pm »