File Coverage

blib/lib/PLS/Server/Request/Initialize.pm
Criterion Covered Total %
statement 46 47 97.8
branch 3 6 50.0
condition 1 3 33.3
subroutine 10 10 100.0
pod 0 1 0.0
total 60 67 89.5


line stmt bran cond sub pod time code
1              
2             use strict;
3 9     9   54 use warnings;
  9         9  
  9         223  
4 9     9   28  
  9         89  
  9         229  
5             use parent 'PLS::Server::Request';
6 9     9   44  
  9         18  
  9         35  
7             use PPI::Document;
8 9     9   565 use URI;
  9         10  
  9         413  
9 9     9   53  
  9         10  
  9         246  
10             use PLS::Parser::Document;
11 9     9   50 use PLS::Parser::Index;
  9         18  
  9         202  
12 9     9   45 use PLS::Server::Response::InitializeResult;
  9         10  
  9         263  
13 9     9   3269 use PLS::Server::State;
  9         18  
  9         233  
14 9     9   45  
  9         19  
  9         1620  
15             =head1 NAME
16              
17             PLS::Server::Request::Initialize
18              
19             =head1 DESCRIPTION
20              
21             This is the first request from the client to the server.
22              
23             The client provides information about itself, and the server performs
24             some initialization for itself and returns its capabilities.
25              
26             =cut
27              
28             {
29             my ($self, $server) = @_;
30              
31 5     5 0 44 my $root_uri = $self->{params}{rootUri};
32             my $workspace_folders = $self->{params}{workspaceFolders};
33 5         39 $workspace_folders = [] if (ref $workspace_folders ne 'ARRAY');
34 5         18 @{$workspace_folders} = map { $_->{uri} } @{$workspace_folders};
35 5 50       58 push @{$workspace_folders}, $root_uri if (not scalar @{$workspace_folders} and length $root_uri);
36 5         27 @{$workspace_folders} = map { URI->new($_)->file } @{$workspace_folders};
  5         31  
  5         49  
  5         24  
37 5 50 33     67  
  0         0  
  5         59  
38 5         13 # Create and cache index object
  5         6088  
  5         166  
  5         19  
39             PLS::Parser::Index->new(workspace_folders => $workspace_folders);
40              
41 5         165 if (length $self->{params}{processId})
42             {
43 5 50       78 $server->monitor_client_process($self->{params}{processId});
44             }
45 5         78  
46             $PLS::Server::State::CLIENT_CAPABILITIES = $self->{params}{capabilities};
47              
48 5         81 return PLS::Server::Response::InitializeResult->new($self);
49             } ## end sub service
50 5         266  
51             1;