Branch Coverage

blib/lib/PLS/Parser/Document.pm
Criterion Covered Total %
branch 99 434 22.8


line true false branch
66 48 3 if (length $args{'uri'}) { }
2 1 elsif (length $args{'path'}) { }
78 1 50 unless length $path and length $uri
87 2 48 unless ref $document eq "PPI::Document"
123 0 0 if $_->lsp_column_number < $column_number
139 0 0 if not &blessed($list) or not $list->isa("PLS::Parser::Element") and $list->type eq "PPI::Structure::List"
149 0 0 unless &blessed($word) and $word->isa("PLS::Parser::Element") and $word->element->isa("PPI::Token::Word")
157 0 0 if (scalar @parts and $parts[-1] ne 'SUPER') { }
167 0 0 if wantarray
184 0 0 if (ref $self->{'index'} ne "PLS::Parser::Index")
192 0 0 if (my($package, $subroutine) = $match->subroutine_package_and_name)
194 0 0 if ($match->cursor_on_package($column_number))
196 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
202 0 0 if ref $this_files_package eq "PLS::Parser::Element::Package" and $this_files_package->name eq $package
205 0 0 if ref $external eq "HASH"
209 0 0 if (length $package)
211 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
214 0 0 if ref $results eq "ARRAY" and scalar @{$results;}
218 0 0 if (ref $this_files_package eq "PLS::Parser::Element::Package" and $this_files_package->name eq $package)
221 0 0 if &blessed($found) and $found->isa("PLS::Parser::Element")
226 0 0 if ref $external eq "HASH"
229 0 0 if (ref $self->{'index'} eq "PLS::Parser::Index")
232 0 0 if ref $results eq "ARRAY" and scalar @{$results;}
238 0 0 if &blessed($found) and $found->isa("PLS::Parser::Element")
240 0 0 if (my($class, $method) = $match->class_method_package_and_name)
242 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
247 0 0 if ref $results eq "ARRAY" and scalar @$results
252 0 0 if &blessed($found) and $found->isa("PLS::Parser::Element")
256 0 0 if ref $external eq "HASH"
258 0 0 if (my $method = $match->method_name)
260 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
267 0 0 if &blessed($found) and $found->isa("PLS::Parser::Element")
270 0 0 if (my($package, $import) = $match->package_name($column_number))
272 0 0 if (length $import) { }
274 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
281 0 0 if ref $external eq "HASH"
286 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
293 0 0 if ref $external eq "HASH"
297 0 0 if (my $variable = $match->variable_name)
304 0 0 if (my $link = $self->pod_link($line_number, $column_number))
310 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
313 0 0 if ref $package eq "ARRAY" and scalar @{$package;}
315 0 0 if length $package_name
321 0 0 if ref $external eq "HASH"
324 0 0 if ref $external eq "HASH"
348 0 0 unless $element->isa("PPI::Token::Pod")
349 0 0 if $element->line_number > $line_number
350 0 0 if $element->line_number + scalar($element->lines) < $line_number
355 0 0 unless scalar $find->in($self->{'document'})
357 0 0 unless open my $fh, "<", $self->get_full_text
361 0 0 unless $. == $line_number
384 0 0 if $start > $column_number or $column_number > $end
414 0 0 if (($package, $import) = $element->package_name($column_number))
419 0 0 if (length $import)
421 0 0 if ($import =~ /^[\$\@\%]/) { }
437 0 0 if $ok
439 0 0 if (($package, $subroutine) = $element->class_method_package_and_name)
449 0 0 if $ok
451 0 0 if ($subroutine = $element->method_name)
460 0 0 if $ok
462 0 0 if (($package, $subroutine) = $element->subroutine_package_and_name)
464 0 0 length $package ? :
476 0 0 if $ok
478 0 0 if ($variable = $element->variable_name)
487 0 0 if $ok
489 0 0 if ($element->type eq "PPI::Token::Operator" and $element->content =~ /^-[rwxoRWXOezsfdlpSbctugkTBMAC]$/)
498 0 0 if $ok
510 45 0 if $self->{'one_line'}
516 0 204 unless $element->line_number == $line_number
517 12 192 if $element->column_number > $column_number
518 35 157 if $element->column_number + length($element->content) < $column_number
543 0 0 if ref $package ne "Module::Metadata"
546 0 0 if ref $doc ne "PLS::Parser::Document"
550 0 0 unless $subroutine->name eq $subroutine_name
572 0 0 unless length $package_name
577 0 0 if ref $metadata ne "Module::Metadata"
580 0 0 if ref $document ne "PLS::Parser::Document"
584 0 0 unless $package->name eq $package_name
620 0 0 unless &blessed($cursor)
622 0 0 if ($cursor->isa('PPI::Structure::Block') or $cursor->isa('PPI::Document')) { }
0 0 elsif ($cursor->isa('PPI::Statement::Compound')) { }
626 0 0 if $child == $prev_cursor
627 0 0 unless &blessed($child)
629 0 0 if ($child->isa("PPI::Statement::Variable") and &any(sub {
634 0 0 if ($child->isa("PPI::Statement::Include") and $child->type eq "use" and $child->pragma eq "vars")
638 0 0 if $1 ne $variable
647 0 0 if ($cursor->type eq 'foreach') { }
651 0 0 if $child == $prev_cursor
652 0 0 unless &blessed($child)
654 0 0 if ($child->isa("PPI::Token::Word") and $child =~ /^my|our|local|state$/)
656 0 0 if (&blessed(scalar $child->snext_sibling) and $child->snext_sibling->isa("PPI::Token::Symbol") and $child->snext_sibling->symbol eq $variable)
668 0 0 unless &blessed($condition) and $condition->isa("PPI::Structure::Condition")
672 0 0 if $child == $prev_cursor
673 0 0 unless &blessed($child)
675 0 0 if ($child->isa("PPI::Statement::Variable") and &any(sub {
684 0 0 if $cursor == $document
687 0 0 unless &blessed($declaration) and $declaration->isa("PPI::Element")
709 0 3 unless $args{'languageId'} eq "perl"
742 0 0 if ref $file ne "SCALAR"
748 0 0 if (ref $change->{'range'} eq 'HASH') { }
760 0 0 if ($#lines >= $change->{'range'}{'start'}{'line'})
770 0 0 if ($#lines >= $change->{'range'}{'end'}{'line'})
781 0 0 if (length $starting_text)
783 0 0 length $replacement[0] ? :
785 0 0 if (length $ending_text)
787 0 0 if (scalar @replacement) { }
843 0 0 if $_[0]->isa("PPI::Statement::Sub") and not $_[0]->isa("PPI::Statement::Scheduled")
863 0 0 if (ref $element eq 'PPI::Statement::Include') { }
873 0 0 unless $element->isa("PPI::Statement::Include")
874 0 0 unless $element->type eq "use"
888 0 0 if (ref $constructor eq 'PPI::Structure::Constructor') { }
930 0 0 if (&blessed($element) and $element->isa('PPI::Statement::Variable')) { }
967 0 0 if ref $text ne "SCALAR"
968 0 0 if ref $text ne "SCALAR"
980 0 0 unless length $lvalue
985 0 0 unless length $variable
1006 0 0 if ref $text ne "SCALAR"
1007 0 0 if ref $text ne "SCALAR"
1016 0 0 unless length $package
1035 0 0 if ref $text ne "SCALAR"
1036 0 0 if ref $text ne "SCALAR"
1064 0 0 if ref $text ne "SCALAR"
1065 0 0 if ref $text ne "SCALAR"
1080 0 0 unless length $constant
1090 0 0 unless length $constant
1103 0 2 if ref $text ne "SCALAR"
1104 0 2 if ref $text ne "SCALAR"
1115 10 0 if ($use =~ /$identifier_rx/)
1120 4 6 if lc $module eq $module
1139 0 0 unless ref $args{'formatting_options'} eq "HASH"
1143 0 0 if (ref $text ne "SCALAR")
1151 0 0 if (ref $range eq 'HASH') { }
1155 0 0 if $range->{'end'}{'character'} == 0
1189 0 0 if (length $args{'formatting_options'}{'tabSize'})
1191 0 0 $args{'formatting_options'}{'insertSpaces'} ? :
1195 0 0 unless length $perltidyrc and -f $perltidyrc and -r $perltidyrc
1204 0 0 if $whole_file and $lines > $range->{'end'}{'line'}
1206 0 0 if $args{'formatting_options'}{'trimTrailingWhitespace'}
1208 0 0 if ($args{'formatting_options'}{'insertFinalNewline'})
1210 0 0 unless $formatted =~ /\n$/
1212 0 0 if ($args{'formatting_options'}{'trimFinalNewlines'})
1222 0 0 if $error == 1 or length $stderr
1271 5 0 if (ref $FILES{$uri} eq 'SCALAR') { }
1278 0 0 unless open my $fh, "<", $file->file
1304 0 50 if ($args{'text'}) { }
50 0 elsif (length $args{'uri'}) { }
1310 45 5 if (ref $FILES{$args{'uri'}} eq 'SCALAR') { }
1320 46 4 if (length $args{'line'})
1323 45 1 if (ref $file eq 'SCALAR') { }
1 0 elsif (open $fh, '<', $file) { }
1330 45 0 if (length $text)
1340 1 0 if (length $text[$args{'line'}])
1349 2 48 unless &blessed($document) and $document->isa("PPI::Document")
1366 0 0 unless $element->isa("PPI::Token::Word")
1367 0 0 unless ref $_->snext_sibling eq "PPI::Token::Operator"
1398 260 23 if $_->lsp_column_number <= $character
1400 99 12 unless $_->type eq "PPI::Token::Word" or $_->type eq "PPI::Token::Label" or $_->type eq "PPI::Token::Symbol" or $_->type eq "PPI::Token::Magic" or $_->type eq "PPI::Token::Quote::Double" or $_->type eq "PPI::Token::Quote::Interpolate" or $_->type eq "PPI::Token::QuoteLike::Regexp" or $_->type eq "PPI::Token::QuoteLike::Command"
1410 31 36 unless &$predicate()
1414 6 36 if (&blessed($element) and $element->isa("PLS::Parser::Element") and $element->type eq "PPI::Token::Operator")
1416 0 0 if (!&blessed(scalar $element->element->previous_sibling) || $element->element->previous_sibling->isa('PPI::Token::Whitespace') and not &blessed(scalar $element->previous_sibling) && $element->previous_sibling->isa('PLS::Parser::Element') && $element->previous_sibling->element->isa('PPI::Token::Word') && $element->previous_sibling->name eq 'sub' and $element->content eq "-")
1436 13 16 if (&blessed($element) and $element->isa("PLS::Parser::Element") and $element->type eq 'PPI::Token::Quote::Double' || $element->type eq 'PPI::Token::Quote::Interpolate' || $element->type eq 'PPI::Token::QuoteLike::Regexp' || $element->type eq 'PPI::Token::QuoteLike::Command' || $element->element->isa('PPI::Token::Regexp'))
1449 0 21 if $string_start <= 0
1453 2 19 if ($string =~ /^"/) { }
14 5 elsif ($string =~ /^(q[qrx]|[ysm]|tr)(\S)/ or $string =~ m[^()(/)]) { }
1462 2 12 if $delimiter eq "{"
1463 2 12 if $delimiter eq "("
1464 2 12 if $delimiter eq "<"
1465 2 12 if $delimiter eq "["
1467 14 0 if ($string =~ /\Q$end_delimiter\E$/) { }
1479 16 5 if ($string =~ /$var_rx/)
1497 13 16 unless (&blessed($element) and $element->isa("PLS::Parser::Element"))
1501 1 0 if (&blessed($regexp) and $regexp->type eq 'PPI::Token::Regexp::Match' && $regexp->content eq 'm' || $regexp->type eq 'PPI::Token::Regexp::Substitute' && $regexp->content eq 's' || $regexp->type eq 'PPI::Token::Regexp::Transliterate' && ($regexp->content eq 'tr' || $regexp->content eq 'y'))
1512 11 18 unless (&blessed($element) and $element->isa("PLS::Parser::Element"))
1521 1 10 if (&blessed($literal) and $literal->element->content eq 'q') { }
1 9 elsif (&blessed($interpolate) and $interpolate->element->content eq 'qq') { }
1 8 elsif (&blessed($qr) and $qr->element->content eq 'qr') { }
1 7 elsif (&blessed($qw) and $qw->element->content eq 'qw') { }
1 12 elsif (&blessed($qx) and $qx->element->content eq 'qx') { }
1543 6 23 unless (&blessed($element) and $element->isa("PLS::Parser::Element"))
1548 1 5 if (&blessed($cast) and $cast->isa("PLS::Parser::Element"))
1554 5 0 if (not &blessed($element) && $element->isa('PLS::Parser::Element') and &blessed($closest_operator) and $closest_operator->isa("PLS::Parser::Element") and $closest_operator->name eq "->" and $closest_operator->lsp_column_number + length($closest_operator->content) == $character)
1571 2 3 if (&blessed(scalar $closest_operator->previous_sibling) and $closest_operator->previous_sibling->isa('PLS::Parser::Element') and $closest_operator->previous_sibling->type eq 'PPI::Token::Word' and not &blessed(scalar $closest_operator->previous_sibling->element->previous_sibling) && $closest_operator->previous_sibling->element->previous_sibling->isa('PPI::Token::Operator') && $closest_operator->previous_sibling->element->previous_sibling eq '->') { }
1588 0 23 unless &blessed($element) and $element->isa("PLS::Parser::Element")
1590 4 19 if ($element->type eq "PPI::Token::Magic")
1592 4 0 if ($element->name =~ /^[\$\@\%]/)
1604 1 0 if ($element->type eq "PPI::Token::Symbol" and $element->lsp_column_number == $character and &blessed(scalar $element->previous_sibling) and $element->previous_sibling->isa("PLS::Parser::Element"))
1611 19 0 if &blessed($parent) and ref $parent eq "PLS::Parser::Element"
1612 0 9 if $element->type eq "PPI::Token::Word" and &blessed($parent) and $parent->isa("PLS::Parser::Element") and $parent->type eq "PPI::Structure::Subscript"
1615 5 0 if ($element->type eq "PPI::Token::Word" and &blessed(scalar $element->previous_sibling) and $element->previous_sibling->isa("PLS::Parser::Element") and $element->previous_sibling->name eq "->")
1623 5 1 if (&blessed($closest_operator) and $closest_operator->isa("PLS::Parser::Element") and $closest_operator->name eq "->" and $element->type eq "PPI::Token::Word" and $element->parent->element == $closest_operator->parent->element)
1641 5 0 if (&blessed(scalar $closest_operator->next_sibling) and $closest_operator->next_sibling->isa("PLS::Parser::Element") and $closest_operator->next_sibling->type eq "PPI::Token::Word" and $closest_operator->ppi_line_number == $closest_operator->next_sibling->ppi_line_number)
1654 2 1 if (&blessed(scalar $closest_operator->previous_sibling) and $closest_operator->previous_sibling->isa("PLS::Parser::Element") and $closest_operator->previous_sibling->type eq "PPI::Token::Word" and !(&blessed(scalar $closest_operator->previous_sibling->previous_sibling) && $closest_operator->previous_sibling->previous_sibling->isa('PLS::Parser::Element')) || $closest_operator->previous_sibling->previous_sibling->name ne '->')
1672 0 1 if (&blessed($closest_operator) and $closest_operator->isa("PLS::Parser::Element") and $closest_operator->name eq "->" and &blessed(scalar $closest_operator->previous_sibling) and $closest_operator->previous_sibling->isa("PLS::Parser::Element") and $closest_operator->previous_sibling->element == $element->element)
1689 0 0 if ($element->name eq ":" and &blessed(scalar $element->previous_sibling) and $element->previous_sibling->isa("PLS::Parser::Element") and $element->previous_sibling->type eq 'PPI::Token::Word' || $element->previous_sibling->type eq 'PPI::Token::Label' and !(&blessed(scalar $element->previous_sibling->previous_sibling) && $element->previous_sibling->previous_sibling->isa('PLS::Parser::Element')) || $element->previous_sibling->previous_sibling->name ne '->')
1710 5 2 if ($element->type eq "PPI::Token::Word" or $element->type eq "PPI::Token::Label" or $element->element->isa("PPI::Token::Quote") or $element->element->isa("PPI::Token::QuoteLike") or $element->element->isa("PPI::Token::Regexp"))
1720 0 14 if &blessed(scalar $element->parent) and $element->parent->isa("PLS::Parser::Element") and $element->parent->element->isa("PPI::Statement::Sub")
1743 0 0 if not &blessed($list) && $list->isa('PLS::Parser::Element') or $list->type ne "PPI::Structure::List"
1747 0 0 if $find->start($list->element)
1749 0 0 unless &blessed($expr) and $expr->isa("PPI::Statement::Expression")
1751 0 0 if $_->isa("PPI::Token::Operator")
1753 0 0 unless scalar @commas
1761 0 0 if ($param->column_number <= $character)
1824 0 0 unless $seqno = $child->isa("PPI::Statement::Include") .. !($child->isa('PPI::Statement::Include') || $child->isa('PPI::Token::Whitespace'))
1825 0 0 if $seqno =~ /E0/
1826 0 0 if $seqno eq 1
1828 0 0 if ($child->isa("PPI::Token::Whitespace"))
1834 0 0 if ($child->pragma eq 'strict' or $child->pragma eq 'warnings') { }
0 0 elsif ($child->pragma eq 'parent' or $child->pragma eq 'base') { }
0 0 elsif ($child->pragma eq 'constant') { }
0 0 elsif (length $child->pragma) { }
1852 0 0 if (Module::CoreList::is_core($child->module) or &any(sub {
1865 0 0 if scalar @special_pragmas
1866 0 0 if scalar @isa_pragmas
1867 0 0 if scalar @pragmas
1868 0 0 if scalar @installed_modules
1869 0 0 if scalar @internal_modules
1870 0 0 if scalar @constant_pragmas