blib/lib/PLS/Server/Response/Location.pm

filter: Statementstmt 36.1% 13 / 36 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 1 totaltotal 29.3% 17 / 58 CC 8 SCAR 38.0
CC
8
Cov
27%
new
72.0
__ANON__
2.0
BEGIN
1.0
CRAP 44.8
« blib/lib/PLS/Server/Request/Workspace/DidChangeWatchedFiles.pm ↑ Summary blib/lib/PLS/Parser/Pod.pm »
1 package PLS::Server::Response::Location;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 ▶use parent q(PLS::Server::Response);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 ▶use PLS::Parser::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 PLS::Server::Response::Location
13  
14 =head1 DESCRIPTION
15  
16 This is a message from the server to the client providing a location.
17 This is typically used to provide the location of the definition of a symbol.
18  
19 =cut
20  
21 sub new
22 0 ▶{
Subroutine new: not called CC=8 SCAR=42.8
Pod undocumented
23 0 my ($class, $request) = @_;
24  
25 my $self = {
26 id => $request->{id},
27 0 result => undef
28 };
29  
30 0 bless $self, $class;
31  
32 0 my ($line, $character) = @{$request->{params}{position}}{qw(line character)};
33  
34 0 my $document = PLS::Parser::Document->new(uri => $request->{params}{textDocument}{uri}, line => $line);
35 0 ▶ return $self if (ref $document ne 'PLS::Parser::Document');
Branch: 1 branch
BranchTrueFalseTotal
if ref $document ne "PLS::Parser::Document" 0 0 0
36  
37 0 my $results = $document->go_to_definition($line, $character);
38  
39 # If there are no results, for a variable, we need to fall back to checking the entire document.
40 0 ▶ if (ref $results ne 'ARRAY' or not scalar @{$results})
Branch: 1 branch
BranchTrueFalseTotal
if (ref $results ne "ARRAY" or not scalar @{$results;}) 0 0 0
Condition0%0/3
ref $results ne "ARRAY" or not scalar @{$results;}
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $results ne "ARRAY" or not scalar @{$results;}
ref $results ne "ARRAY" not scalar @{$results;}
Truth table0%0/3
A or not(B)
A= ref $results ne "ARRAY"B= not scalar @{$results;}
ABresult
1X1
011
000
41 {
42 0 my @matches = $document->find_elements_at_location($line, $character);
43  
44 0 ▶ if (List::Util::any { $_->variable_name() } @matches)
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&List::Util::any(sub { $_->variable_name; } , @matches)) 0 0 0
45 {
46 0 $document = PLS::Parser::Document->new(uri => $request->{params}{textDocument}{uri});
47 0 ▶ return $self if (ref $document ne 'PLS::Parser::Document');
Branch: 1 branch
BranchTrueFalseTotal
if ref $document ne "PLS::Parser::Document" 0 0 0
48 0 $results = $document->go_to_definition($line, $character);
49 } ## end if (List::Util::any { ...})
50 } ## end if (ref $results ne 'ARRAY'...)
51  
52 0 ▶ if (ref $results eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $results eq "ARRAY") 0 0 0
53 {
54 0 foreach my $result (@{$results})
55 {
56 0 delete @{$result}{qw(package signature kind)};
57 }
58 } ## end if (ref $results eq 'ARRAY'...)
59  
60 0 $self->{result} = $results;
61 0 return $self;
62 } ## end sub new
63  
64 13 1;
« blib/lib/PLS/Server/Request/Workspace/DidChangeWatchedFiles.pm ↑ Summary blib/lib/PLS/Parser/Pod.pm »