| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
|
3
|
9
|
|
|
9
|
|
45
|
use warnings; |
|
|
9
|
|
|
|
|
26
|
|
|
|
9
|
|
|
|
|
206
|
|
|
4
|
9
|
|
|
9
|
|
36
|
|
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
188
|
|
|
5
|
|
|
|
|
|
|
use parent q(PLS::Server::Response); |
|
6
|
9
|
|
|
9
|
|
36
|
|
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
43
|
|
|
7
|
|
|
|
|
|
|
use IO::Async::Function; |
|
8
|
9
|
|
|
9
|
|
376
|
use IO::Async::Loop; |
|
|
9
|
|
|
|
|
9
|
|
|
|
9
|
|
|
|
|
238
|
|
|
9
|
9
|
|
|
9
|
|
51
|
|
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
2336
|
|
|
10
|
|
|
|
|
|
|
use PLS::Parser::Document; |
|
11
|
9
|
|
|
9
|
|
44
|
use PLS::Server::State; |
|
|
9
|
|
|
|
|
23
|
|
|
|
9
|
|
|
|
|
316
|
|
|
12
|
9
|
|
|
9
|
|
37
|
|
|
|
9
|
|
|
|
|
26
|
|
|
|
9
|
|
|
|
|
2764
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PLS::Server::Response::Formatting |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This is a message from the server to the client with the current document |
|
20
|
|
|
|
|
|
|
after having been formatted. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Set up formatting as a function because it can be slow |
|
25
|
|
|
|
|
|
|
my $loop = IO::Async::Loop->new(); |
|
26
|
|
|
|
|
|
|
my $function = IO::Async::Function->new( |
|
27
|
|
|
|
|
|
|
code => sub { |
|
28
|
|
|
|
|
|
|
my ($self, $request, $text, $perltidyrc) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my ($ok, $formatted) = PLS::Parser::Document->format(text => $text, formatting_options => $request->{params}{options}, perltidyrc => $perltidyrc); |
|
31
|
|
|
|
|
|
|
return $ok, $formatted; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
$loop->add($function); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
{ |
|
37
|
|
|
|
|
|
|
my ($class, $request) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
|
1
|
0
|
8
|
my $self = bless {id => $request->{id}}, $class; |
|
40
|
|
|
|
|
|
|
my $text = PLS::Parser::Document->text_from_uri($request->{params}{textDocument}{uri}); |
|
41
|
1
|
|
|
|
|
15
|
|
|
42
|
1
|
|
|
|
|
30
|
return $function->call(args => [$self, $request, $text, $PLS::Server::State::CONFIG->{perltidy}{perltidyrc}])->then( |
|
43
|
|
|
|
|
|
|
sub { |
|
44
|
|
|
|
|
|
|
my ($ok, $formatted) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
|
|
if ($ok) |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
0
|
0
|
|
|
|
|
$self->{result} = $formatted; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
|
|
|
|
|
else |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
|
|
|
|
|
|
$self->{error} = $formatted; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
0
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return $self; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
0
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
} ## end sub new |
|
59
|
1
|
|
|
|
|
14
|
|
|
60
|
|
|
|
|
|
|
1; |