File Coverage

blib/lib/PLS/Server/Request/Factory.pm
Criterion Covered Total %
statement 27 30 90.0
branch 3 8 37.5
condition 5 6 83.3
subroutine 8 8 100.0
pod 0 1 0.0
total 43 53 81.1


line stmt bran cond sub pod time code
1              
2             use strict;
3 9     9   62 use warnings;
  9         18  
  9         234  
4 9     9   30  
  9         18  
  9         179  
5             use PLS::Server::Method::CompletionItem;
6 9     9   2977 use PLS::Server::Method::TextDocument;
  9         26  
  9         268  
7 9     9   4000 use PLS::Server::Method::Workspace;
  9         135  
  9         1269  
8 9     9   8265 use PLS::Server::Method::ServerMethod;
  9         51  
  9         272  
9 9     9   3354 use PLS::Server::Request;
  9         35  
  9         353  
10 9     9   118  
  9         18  
  9         1675  
11             =head1 NAME
12              
13             PLS::Server::Request::Factory
14              
15             =head1 DESCRIPTION
16              
17             This is a factory class. Given a request from the client, this
18             will determine the appropriate subclass of L<PLS::Server::Request> for the request
19             and return it.
20              
21             =cut
22              
23             {
24             my ($class, $request) = @_;
25              
26 19     19 0 73 my $method = $request->{method};
27             ($method) = split '/', $method;
28 19         78  
29 19         77 # create and return request classes here
30              
31             if ( PLS::Server::Method::ServerMethod::is_server_method($method)
32             or not $PLS::Server::State::INITIALIZED
33 19 100 66     106 or $PLS::Server::State::SHUTDOWN)
    50 100        
    0          
    0          
34             {
35             return PLS::Server::Method::ServerMethod::get_request($request);
36             } ## end if (PLS::Server::Method::ServerMethod::is_server_method...)
37 16         103 elsif ($method eq 'textDocument')
38             {
39             return PLS::Server::Method::TextDocument::get_request($request);
40             }
41 3         61 elsif ($method eq 'workspace')
42             {
43             return PLS::Server::Method::Workspace::get_request($request);
44             }
45 0           elsif ($method eq 'completionItem')
46             {
47             return PLS::Server::Method::CompletionItem::get_request($request);
48             }
49 0            
50             return PLS::Server::Request->new($request);
51             } ## end sub new
52 0            
53             1;