line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
9
|
|
|
9
|
|
46
|
use warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
288
|
|
4
|
9
|
|
|
9
|
|
44
|
|
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
198
|
|
5
|
|
|
|
|
|
|
use parent q(PLS::Server::Response); |
6
|
9
|
|
|
9
|
|
44
|
|
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
37
|
|
7
|
|
|
|
|
|
|
use IO::Async::Function; |
8
|
9
|
|
|
9
|
|
653
|
use IO::Async::Loop; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
231
|
|
9
|
9
|
|
|
9
|
|
52
|
|
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
1559
|
|
10
|
|
|
|
|
|
|
use PLS::Parser::Document; |
11
|
9
|
|
|
9
|
|
51
|
use PLS::Server::State; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
347
|
|
12
|
9
|
|
|
9
|
|
63
|
|
|
9
|
|
|
|
|
9
|
|
|
9
|
|
|
|
|
2774
|
|
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
|
|
|
|
|
11
|
|
42
|
1
|
|
|
|
|
28
|
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
|
|
|
|
|
16
|
|
60
|
|
|
|
|
|
|
1; |