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

filter: Statementstmt 52.0% 25 / 48 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 57.1% 8 / 14 Podpod 0.0% 0 / 2 totaltotal 44.0% 33 / 75 CC 4 SCAR 17.5
CC
4
Cov
45%
__ANON__
20.0
new
2.0
__ANON__
2.0
CRAP 5.8
« blib/lib/PLS/Server/Cache.pm ↑ Summary blib/lib/PLS/Server/Response/Hover.pm »
1 package PLS::Server::Response::DocumentSymbol;
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 'PLS::Server::Response';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 13 ▶use IO::Async::Loop;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use IO::Async::Timer::Countdown;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 13 ▶use PLS::Parser::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 13 ▶use PLS::Parser::DocumentSymbols;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 =head1 NAME
17  
18 PLS::Server::Response::DocumentSymbol
19  
20 =head1 DESCRIPTION
21  
22 This is a message from the server to the client with a list
23 of symbols in the current document.
24  
25 =cut
26  
27 sub new
28 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my ($class, $request) = @_;
30  
31 0 my $self = bless {id => $request->{id}, result => undef}, $class;
32  
33 0 my $uri = $request->{params}{textDocument}{uri};
34  
35 # Delay document symbols by a couple of seconds to allow cancelling before processing starts.
36 0 my $future = Future->new();
37 my $timer = IO::Async::Timer::Countdown->new(
38 delay => 2,
39 0 ▶ on_expire => sub { $self->on_expire($uri, $future) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 remove_on_expire => 1
41 );
42  
43 0 IO::Async::Loop->new->add($timer->start());
44  
45 # When the future is canceled, make sure to stop the timer so that it never actually starts generating document symbols.
46 $future->on_cancel(
47 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 0 $timer->stop();
49 0 $timer->remove_from_parent();
50 }
51 0 );
52  
53 0 return $future;
54 } ## end sub new
55  
56 sub on_expire
57 0 ▶{
Subroutine on_expire: not called CC=1 SCAR=6.9
Pod undocumented
58 0 my ($self, $uri, $future) = @_;
59  
60 0 my $version = PLS::Parser::Document::uri_version($uri);
61  
62 PLS::Parser::DocumentSymbols->get_all_document_symbols_async($uri)->on_done(
63 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
64 0 my ($symbols) = @_;
65  
66 0 my $current_version = PLS::Parser::Document::uri_version($uri);
67  
68 0 ▶ if (not length $current_version or length $version and $current_version > $version)
Branch: 1 branch
BranchTrueFalseTotal
if (not length $current_version or length $version and $current_version > $version) 0 0 0
Condition0%0/6
not length $current_version or length $version and $current_version > $version
l!l&&r!l&&!r
000
length $version and $current_version > $version
!ll&&!rl&&r
000
MC/DC0%0/3
not length $current_version or length $version and $current_version > $version
not length $current_version length $version $current_version > $version
Truth table0%0/4
not(A) or B and C
A= not length $current_versionB= length $versionC= $current_version > $version
ABCresult
1XX1
0111
00X0
0100
69 {
70 0 $future->done($self);
71 0 return;
72 }
73  
74 0 $self->{result} = $symbols;
75 0 $future->done($self);
76 }
77 )->on_fail(
78 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 0 $future->done($self);
80 }
81 0 )->retain();
82  
83 0 return;
84 } ## end sub on_expire
85  
86 13 1;
« blib/lib/PLS/Server/Cache.pm ↑ Summary blib/lib/PLS/Server/Response/Hover.pm »