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   45 use warnings;
  9         17  
  9         197  
4 9     9   36  
  9         17  
  9         176  
5             use parent 'PLS::Server::Request';
6 9     9   116  
  9         26  
  9         52  
7             use PPI::Document;
8 9     9   630 use URI;
  9         26  
  9         449  
9 9     9   45  
  9         17  
  9         178  
10             use PLS::Parser::Document;
11 9     9   37 use PLS::Parser::Index;
  9         18  
  9         204  
12 9     9   92 use PLS::Server::Response::InitializeResult;
  9         18  
  9         237  
13 9     9   3001 use PLS::Server::State;
  9         26  
  9         231  
14 9     9   45  
  9         17  
  9         1450  
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 26 my $root_uri = $self->{params}{rootUri};
32             my $workspace_folders = $self->{params}{workspaceFolders};
33 5         32 $workspace_folders = [] if (ref $workspace_folders ne 'ARRAY');
34 5         14 @{$workspace_folders} = map { $_->{uri} } @{$workspace_folders};
35 5 50       31 push @{$workspace_folders}, $root_uri if (not scalar @{$workspace_folders} and length $root_uri);
36 5         7 @{$workspace_folders} = map { URI->new($_)->file } @{$workspace_folders};
  5         20  
  5         39  
  5         12  
37 5 50 33     10  
  0         0  
  5         26  
38 5         12 # Create and cache index object
  5         4981  
  5         154  
  5         33  
39             PLS::Parser::Index->new(workspace_folders => $workspace_folders);
40              
41 5         154 if (length $self->{params}{processId})
42             {
43 5 50       22 $server->monitor_client_process($self->{params}{processId});
44             }
45 5         76  
46             $PLS::Server::State::CLIENT_CAPABILITIES = $self->{params}{capabilities};
47              
48 5         83 return PLS::Server::Response::InitializeResult->new($self);
49             } ## end sub service
50 5         247  
51             1;