Branch Coverage

blib/lib/PLS/Parser/Document.pm
Criterion Covered Total %
branch 79 426 18.5


line true false branch
66 30 3 if (length $args{'uri'}) { }
2 1 elsif (length $args{'path'}) { }
78 1 32 unless length $path and length $uri
87 2 30 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")
151 0 0 if wantarray
168 0 0 if (ref $self->{'index'} ne "PLS::Parser::Index")
176 0 0 if (my($package, $subroutine) = $match->subroutine_package_and_name)
178 0 0 if ($match->cursor_on_package($column_number))
180 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
186 0 0 if ref $this_files_package eq "PLS::Parser::Element::Package" and $this_files_package->name eq $package
189 0 0 if ref $external eq "HASH"
193 0 0 if (length $package)
195 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
198 0 0 if ref $results eq "ARRAY" and scalar @{$results;}
202 0 0 if (ref $this_files_package eq "PLS::Parser::Element::Package" and $this_files_package->name eq $package)
205 0 0 if &blessed($found) and $found->isa("PLS::Parser::Element")
210 0 0 if ref $external eq "HASH"
213 0 0 if (ref $self->{'index'} eq "PLS::Parser::Index")
216 0 0 if ref $results eq "ARRAY" and scalar @{$results;}
222 0 0 if &blessed($found) and $found->isa("PLS::Parser::Element")
224 0 0 if (my($class, $method) = $match->class_method_package_and_name)
226 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
231 0 0 if ref $results eq "ARRAY" and scalar @$results
236 0 0 if &blessed($found) and $found->isa("PLS::Parser::Element")
240 0 0 if ref $external eq "HASH"
242 0 0 if (my $method = $match->method_name)
244 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
251 0 0 if &blessed($found) and $found->isa("PLS::Parser::Element")
254 0 0 if (my($package, $import) = $match->package_name($column_number))
256 0 0 if (length $import) { }
258 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
265 0 0 if ref $external eq "HASH"
270 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
277 0 0 if ref $external eq "HASH"
281 0 0 if (my $variable = $match->variable_name)
288 0 0 if (my $link = $self->pod_link($line_number, $column_number))
294 0 0 if (ref $self->{'index'} eq 'PLS::Parser::Index') { }
297 0 0 if ref $package eq "ARRAY" and scalar @{$package;}
299 0 0 if length $package_name
305 0 0 if ref $external eq "HASH"
308 0 0 if ref $external eq "HASH"
332 0 0 unless $element->isa("PPI::Token::Pod")
333 0 0 if $element->line_number > $line_number
334 0 0 if $element->line_number + scalar($element->lines) < $line_number
339 0 0 unless scalar $find->in($self->{'document'})
341 0 0 unless open my $fh, "<", $self->get_full_text
345 0 0 unless $. == $line_number
368 0 0 if $start > $column_number or $column_number > $end
398 0 0 if (($package, $import) = $element->package_name($column_number))
403 0 0 if (length $import)
405 0 0 if ($import =~ /^[\$\@\%]/) { }
421 0 0 if $ok
423 0 0 if (($package, $subroutine) = $element->class_method_package_and_name)
433 0 0 if $ok
435 0 0 if ($subroutine = $element->method_name)
444 0 0 if $ok
446 0 0 if (($package, $subroutine) = $element->subroutine_package_and_name)
448 0 0 length $package ? :
460 0 0 if $ok
462 0 0 if ($variable = $element->variable_name)
471 0 0 if $ok
473 0 0 if ($element->type eq "PPI::Token::Operator" and $element->content =~ /^-[rwxoRWXOezsfdlpSbctugkTBMAC]$/)
482 0 0 if $ok
494 27 0 if $self->{'one_line'}
500 0 137 unless $element->line_number == $line_number
501 4 133 if $element->column_number > $column_number
502 32 101 if $element->column_number + length($element->content) < $column_number
527 0 0 if ref $package ne "Module::Metadata"
530 0 0 if ref $doc ne "PLS::Parser::Document"
534 0 0 unless $subroutine->name eq $subroutine_name
556 0 0 unless length $package_name
561 0 0 if ref $metadata ne "Module::Metadata"
564 0 0 if ref $document ne "PLS::Parser::Document"
568 0 0 unless $package->name eq $package_name
604 0 0 unless &blessed($cursor)
606 0 0 if ($cursor->isa('PPI::Structure::Block') or $cursor->isa('PPI::Document')) { }
0 0 elsif ($cursor->isa('PPI::Statement::Compound')) { }
610 0 0 if $child == $prev_cursor
611 0 0 unless &blessed($child)
613 0 0 if ($child->isa("PPI::Statement::Variable") and &any(sub {
618 0 0 if ($child->isa("PPI::Statement::Include") and $child->type eq "use" and $child->pragma eq "vars")
622 0 0 if $1 ne $variable
631 0 0 if ($cursor->type eq 'foreach') { }
635 0 0 if $child == $prev_cursor
636 0 0 unless &blessed($child)
638 0 0 if ($child->isa("PPI::Token::Word") and $child =~ /^my|our|local|state$/)
640 0 0 if (&blessed(scalar $child->snext_sibling) and $child->snext_sibling->isa("PPI::Token::Symbol") and $child->snext_sibling->symbol eq $variable)
652 0 0 unless &blessed($condition) and $condition->isa("PPI::Structure::Condition")
656 0 0 if $child == $prev_cursor
657 0 0 unless &blessed($child)
659 0 0 if ($child->isa("PPI::Statement::Variable") and &any(sub {
668 0 0 if $cursor == $document
671 0 0 unless &blessed($declaration) and $declaration->isa("PPI::Element")
693 0 3 unless $args{'languageId'} eq "perl"
726 0 0 if ref $file ne "SCALAR"
732 0 0 if (ref $change->{'range'} eq 'HASH') { }
744 0 0 if ($#lines >= $change->{'range'}{'start'}{'line'})
754 0 0 if ($#lines >= $change->{'range'}{'end'}{'line'})
765 0 0 if (length $starting_text)
767 0 0 length $replacement[0] ? :
769 0 0 if (length $ending_text)
771 0 0 if (scalar @replacement) { }
827 0 0 if $_[0]->isa("PPI::Statement::Sub") and not $_[0]->isa("PPI::Statement::Scheduled")
847 0 0 if (ref $element eq 'PPI::Statement::Include') { }
857 0 0 unless $element->isa("PPI::Statement::Include")
858 0 0 unless $element->type eq "use"
872 0 0 if (ref $constructor eq 'PPI::Structure::Constructor') { }
914 0 0 if (&blessed($element) and $element->isa('PPI::Statement::Variable')) { }
951 0 0 if ref $text ne "SCALAR"
952 0 0 if ref $text ne "SCALAR"
964 0 0 unless length $lvalue
969 0 0 unless length $variable
990 0 0 if ref $text ne "SCALAR"
991 0 0 if ref $text ne "SCALAR"
999 0 0 unless length $package
1018 0 0 if ref $text ne "SCALAR"
1019 0 0 if ref $text ne "SCALAR"
1048 0 0 if ref $text ne "SCALAR"
1049 0 0 if ref $text ne "SCALAR"
1064 0 0 unless length $constant
1074 0 0 unless length $constant
1087 0 0 if ref $text ne "SCALAR"
1088 0 0 if ref $text ne "SCALAR"
1099 0 0 if ($use =~ /$identifier_rx/)
1104 0 0 if lc $module eq $module
1123 0 0 unless ref $args{'formatting_options'} eq "HASH"
1127 0 0 if (ref $text ne "SCALAR")
1135 0 0 if (ref $range eq 'HASH') { }
1139 0 0 if $range->{'end'}{'character'} == 0
1173 0 0 if (length $args{'formatting_options'}{'tabSize'})
1175 0 0 $args{'formatting_options'}{'insertSpaces'} ? :
1179 0 0 unless length $perltidyrc and -f $perltidyrc and -r $perltidyrc
1188 0 0 if $whole_file and $lines > $range->{'end'}{'line'}
1190 0 0 if $args{'formatting_options'}{'trimTrailingWhitespace'}
1192 0 0 if ($args{'formatting_options'}{'insertFinalNewline'})
1194 0 0 unless $formatted =~ /\n$/
1196 0 0 if ($args{'formatting_options'}{'trimFinalNewlines'})
1206 0 0 if $error == 1 or length $stderr
1255 3 0 if (ref $FILES{$uri} eq 'SCALAR') { }
1262 0 0 unless open my $fh, "<", $file->file
1288 0 32 if ($args{'text'}) { }
32 0 elsif (length $args{'uri'}) { }
1294 27 5 if (ref $FILES{$args{'uri'}} eq 'SCALAR') { }
1304 28 4 if (length $args{'line'})
1307 27 1 if (ref $file eq 'SCALAR') { }
1 0 elsif (open $fh, '<', $file) { }
1314 27 0 if (length $text)
1324 1 0 if (length $text[$args{'line'}])
1333 2 30 unless &blessed($document) and $document->isa("PPI::Document")
1350 0 0 unless $element->isa("PPI::Token::Word")
1351 0 0 unless ref $_->snext_sibling eq "PPI::Token::Operator"
1382 194 11 if $_->lsp_column_number <= $character
1385 27 2 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::Operator" 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"
1398 4 20 if (&blessed($element) and $element->isa("PLS::Parser::Element") and $element->type eq "PPI::Token::Operator")
1400 0 4 if !&blessed(scalar $element->element->previous_sibling) || $element->element->previous_sibling->isa('PPI::Token::Whitespace') and $element->content eq "-"
1404 3 15 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'))
1417 0 5 if $string_start <= 0
1421 0 5 if ($string =~ /^"/) { }
0 5 elsif ($string =~ /^(q[qrx]|[ysm]|tr)(\S)/ or $string =~ m[^()(/)]) { }
1430 0 0 if $delimiter eq "{"
1431 0 0 if $delimiter eq "("
1432 0 0 if $delimiter eq ">"
1433 0 0 if $delimiter eq "]"
1435 0 0 if ($string =~ /\Q$end_delimiter\E$/) { }
1447 0 5 if ($string =~ /$var_rx/)
1465 12 15 unless (&blessed($element) and $element->isa("PLS::Parser::Element"))
1469 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'))
1480 10 17 unless (&blessed($element) and $element->isa("PLS::Parser::Element"))
1489 1 9 if (&blessed($literal) and $literal->element->content eq 'q') { }
1 8 elsif (&blessed($interpolate) and $interpolate->element->content eq 'qq') { }
1 7 elsif (&blessed($qr) and $qr->element->content eq 'qr') { }
1 6 elsif (&blessed($qw) and $qw->element->content eq 'qw') { }
1 10 elsif (&blessed($qx) and $qx->element->content eq 'qx') { }
1511 5 22 unless (&blessed($element) and $element->isa("PLS::Parser::Element"))
1516 1 4 if (&blessed($cast) and $cast->isa("PLS::Parser::Element"))
1522 4 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)
1539 2 2 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 '->') { }
1556 0 22 unless &blessed($element) and $element->isa("PLS::Parser::Element")
1558 4 18 if ($element->type eq "PPI::Token::Magic")
1566 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"))
1573 18 0 if &blessed($parent) and ref $parent eq "PLS::Parser::Element"
1574 0 8 if $element->type eq "PPI::Token::Word" and &blessed($parent) and $parent->isa("PLS::Parser::Element") and $parent->type eq "PPI::Structure::Subscript"
1577 4 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 "->")
1585 4 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)
1603 4 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)
1616 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 '->')
1634 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)
1651 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 '->')
1672 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"))
1700 0 0 if not &blessed($list) && $list->isa('PLS::Parser::Element') or $list->type ne "PPI::Structure::List"
1704 0 0 if $find->start($list->element)
1706 0 0 unless &blessed($expr) and $expr->isa("PPI::Statement::Expression")
1708 0 0 if $_->isa("PPI::Token::Operator")
1710 0 0 unless scalar @commas
1718 0 0 if ($param->column_number <= $character)
1781 0 0 unless $seqno = $child->isa("PPI::Statement::Include") .. !($child->isa('PPI::Statement::Include') || $child->isa('PPI::Token::Whitespace'))
1782 0 0 if $seqno =~ /E0/
1783 0 0 if $seqno eq 1
1785 0 0 if ($child->isa("PPI::Token::Whitespace"))
1791 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) { }
1809 0 0 if (Module::CoreList::is_core($child->module) or &any(sub {
1822 0 0 if scalar @special_pragmas
1823 0 0 if scalar @isa_pragmas
1824 0 0 if scalar @pragmas
1825 0 0 if scalar @installed_modules
1826 0 0 if scalar @internal_modules
1827 0 0 if scalar @constant_pragmas