PLS/Server/Response/Formatting.pm

filter: Statementstmt 67.5% 25 / 37 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 1 totaltotal 64.0% 32 / 50 CC 2 SCAR 7.4
CC
2
Cov
64%
__ANON__
6.0
__ANON__
2.0
new
2.0
CRAP 2.1
« PLS/Server/Request/Initialize.pm ↑ Summary PLS/Server/Request/Initialized.pm »
1 package PLS::Server::Response::Formatting;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶use parent q(PLS::Server::Response);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use IO::Async::Function;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use IO::Async::Loop;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 ▶use PLS::Parser::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use PLS::Server::State;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 =head1 NAME
15  
16 PLS::Server::Response::Formatting
17  
18 =head1 DESCRIPTION
19  
20 This is a message from the server to the client with the current document
21 after having been formatted.
22  
23 =cut
24  
25 # Set up formatting as a function because it can be slow
26 9 my $loop = IO::Async::Loop->new();
27 my $function = IO::Async::Function->new(
28 code => sub {
29 0 ▶ my ($self, $request, $text, $perltidyrc) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
30  
31 0 my ($ok, $formatted) = PLS::Parser::Document->format(text => $text, formatting_options => $request->{params}{options}, perltidyrc => $perltidyrc);
32 0 return $ok, $formatted;
33 }
34 9 );
35 9 $loop->add($function);
36  
37 sub new
38 {
39 0 ▶ my ($class, $request) = @_;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
40  
41 0 my $self = bless {id => $request->{id}}, $class;
42 0 my $text = PLS::Parser::Document->text_from_uri($request->{params}{textDocument}{uri});
43  
44 return $function->call(args => [$self, $request, $text, $PLS::Server::State::CONFIG->{perltidy}{perltidyrc}])->then(
45 sub {
46 0 ▶ my ($ok, $formatted) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
47  
48 0 ▶ if ($ok)
Branch: 1 branch
BranchTrueFalseTotal
if ($ok) { } 0 0 0
49 {
50 0 $self->{result} = $formatted;
51 }
52 else
53 {
54 0 $self->{error} = $formatted;
55 }
56  
57 0 return $self;
58 }
59 0 );
60 } ## end sub new
61  
62 9 1;
« PLS/Server/Request/Initialize.pm ↑ Summary PLS/Server/Request/Initialized.pm »