line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
9
|
|
|
9
|
|
53
|
use warnings; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
198
|
|
4
|
9
|
|
|
9
|
|
45
|
|
|
9
|
|
|
|
|
73
|
|
|
9
|
|
|
|
|
239
|
|
5
|
|
|
|
|
|
|
use parent q(PLS::Server::Response); |
6
|
9
|
|
|
9
|
|
59
|
|
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
36
|
|
7
|
|
|
|
|
|
|
use IO::Async::Function; |
8
|
9
|
|
|
9
|
|
784
|
use IO::Async::Loop; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
362
|
|
9
|
9
|
|
|
9
|
|
84
|
|
|
9
|
|
|
|
|
58
|
|
|
9
|
|
|
|
|
308
|
|
10
|
|
|
|
|
|
|
use PLS::Parser::Document; |
11
|
9
|
|
|
9
|
|
52
|
use PLS::Server::State; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
352
|
|
12
|
9
|
|
|
9
|
|
66
|
|
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
3077
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PLS::Server::Response::RangeFormatting |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This is a message from the server to the client with a document range |
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_range(text => $text, range => $request->{params}{range}, 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
|
0
|
|
|
0
|
0
|
|
if (ref $request->{params}{options} eq 'HASH') |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
0
|
|
|
|
|
# these options aren't really valid for range formatting |
42
|
|
|
|
|
|
|
delete $request->{params}{options}{trimFinalNewlines}; |
43
|
|
|
|
|
|
|
delete $request->{params}{options}{insertFinalNewline}; |
44
|
0
|
|
|
|
|
|
} ## end if (ref $request->{params...}) |
45
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $self = bless {id => $request->{id}}, $class; |
47
|
|
|
|
|
|
|
my $text = PLS::Parser::Document->text_from_uri($request->{params}{textDocument}{uri}); |
48
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $function->call(args => [$self, $request, $text, $PLS::Server::State::CONFIG->{perltidy}{perltidyrc}])->then( |
50
|
|
|
|
|
|
|
sub { |
51
|
|
|
|
|
|
|
my ($ok, $formatted) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
|
|
if ($ok) |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
0
|
|
|
|
|
$self->{result} = $formatted; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
else |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
$self->{error} = $formatted; |
60
|
|
|
|
|
|
|
} |
61
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} ## end sub new |
66
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |