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             package PLS::Server::Request::Factory;
2              
3 9     9   55 use strict;
  9         9  
  9         223  
4 9     9   37 use warnings;
  9         17  
  9         300  
5              
6 9     9   3002 use PLS::Server::Method::CompletionItem;
  9         26  
  9         487  
7 9     9   3289 use PLS::Server::Method::TextDocument;
  9         184  
  9         1323  
8 9     9   7929 use PLS::Server::Method::Workspace;
  9         26  
  9         271  
9 9     9   3027 use PLS::Server::Method::ServerMethod;
  9         19  
  9         327  
10 9     9   61 use PLS::Server::Request;
  9         9  
  9         1583  
11              
12             =head1 NAME
13              
14             PLS::Server::Request::Factory
15              
16             =head1 DESCRIPTION
17              
18             This is a factory class. Given a request from the client, this
19             will determine the appropriate subclass of L<PLS::Server::Request> for the request
20             and return it.
21              
22             =cut
23              
24             sub new
25             {
26 19     19 0 73 my ($class, $request) = @_;
27              
28 19         51 my $method = $request->{method};
29 19         83 ($method) = split '/', $method;
30              
31             # create and return request classes here
32              
33 19 100 66     226 if ( PLS::Server::Method::ServerMethod::is_server_method($method)
    50 100        
    0          
    0          
34             or not $PLS::Server::State::INITIALIZED
35             or $PLS::Server::State::SHUTDOWN)
36             {
37 16         119 return PLS::Server::Method::ServerMethod::get_request($request);
38             } ## end if (PLS::Server::Method::ServerMethod::is_server_method...)
39             elsif ($method eq 'textDocument')
40             {
41 3         28 return PLS::Server::Method::TextDocument::get_request($request);
42             }
43             elsif ($method eq 'workspace')
44             {
45 0           return PLS::Server::Method::Workspace::get_request($request);
46             }
47             elsif ($method eq 'completionItem')
48             {
49 0           return PLS::Server::Method::CompletionItem::get_request($request);
50             }
51              
52 0           return PLS::Server::Request->new($request);
53             } ## end sub new
54              
55             1;