line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
9
|
|
|
9
|
|
61
|
use warnings; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
213
|
|
4
|
9
|
|
|
9
|
|
45
|
|
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
203
|
|
5
|
|
|
|
|
|
|
use parent 'PLS::Server::Request'; |
6
|
9
|
|
|
9
|
|
44
|
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
53
|
|
7
|
|
|
|
|
|
|
use feature 'state'; |
8
|
9
|
|
|
9
|
|
428
|
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
778
|
|
9
|
|
|
|
|
|
|
use IO::Async::Loop; |
10
|
9
|
|
|
9
|
|
61
|
use IO::Async::Timer::Countdown; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
266
|
|
11
|
9
|
|
|
9
|
|
59
|
|
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
221
|
|
12
|
|
|
|
|
|
|
use PLS::Parser::Document; |
13
|
9
|
|
|
9
|
|
45
|
use PLS::Parser::Index; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
215
|
|
14
|
9
|
|
|
9
|
|
53
|
use PLS::Server::Request::TextDocument::PublishDiagnostics; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
200
|
|
15
|
9
|
|
|
9
|
|
3211
|
|
|
9
|
|
|
|
|
151
|
|
|
9
|
|
|
|
|
6190
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
PLS::Server::Request::TextDocument::DidChange |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This is a notification from the client to the server that |
23
|
|
|
|
|
|
|
a text document was changed. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
my ($self, $server) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
0
|
|
return unless (ref $self->{params}{contentChanges} eq 'ARRAY'); |
31
|
|
|
|
|
|
|
PLS::Parser::Document->update_file( |
32
|
0
|
0
|
|
|
|
|
uri => $self->{params}{textDocument}{uri}, |
33
|
|
|
|
|
|
|
changes => $self->{params}{contentChanges}, |
34
|
|
|
|
|
|
|
version => $self->{params}{textDocument}{version} |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
state %timers; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $uri = $self->{params}{textDocument}{uri}; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
if (ref $timers{$uri} eq 'IO::Async::Timer::Countdown') |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
0
|
|
|
|
|
# If we get another change before the timer goes off, reset the timer. |
44
|
|
|
|
|
|
|
# This will allow us to limit the diagnostics to a time one second after the user stopped typing. |
45
|
|
|
|
|
|
|
$timers{$uri}->reset(); |
46
|
|
|
|
|
|
|
} ## end if (ref $timers{$uri} ...) |
47
|
0
|
|
|
|
|
|
else |
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
$timers{$uri} = IO::Async::Timer::Countdown->new( |
50
|
|
|
|
|
|
|
delay => 2, |
51
|
|
|
|
|
|
|
on_expire => sub { |
52
|
|
|
|
|
|
|
my $index = PLS::Parser::Index->new(); |
53
|
|
|
|
|
|
|
$index->index_files($uri)->then(sub { Future->wait_all(@_) })->retain(); |
54
|
0
|
|
|
0
|
|
|
|
55
|
0
|
|
|
|
|
|
$server->send_server_request(PLS::Server::Request::TextDocument::PublishDiagnostics->new(uri => $uri)); |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
delete $timers{$uri}; |
57
|
0
|
|
|
|
|
|
}, |
58
|
0
|
|
|
|
|
|
remove_on_expire => 1 |
59
|
|
|
|
|
|
|
); |
60
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $loop = IO::Async::Loop->new(); |
62
|
|
|
|
|
|
|
$loop->add($timers{$uri}); |
63
|
0
|
|
|
|
|
|
$timers{$uri}->start(); |
64
|
0
|
|
|
|
|
|
} ## end else [ if (ref $timers{$uri} ...)] |
65
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return; |
67
|
|
|
|
|
|
|
} ## end sub service |
68
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |