File Coverage

blib/lib/PLS/Server/Request/Initialize.pm
Criterion Covered Total %
statement 46 47 97.8
branch 2 4 50.0
condition 1 3 33.3
subroutine 10 10 100.0
pod 0 1 0.0
total 59 65 90.7


line stmt bran cond sub pod time code
1             package PLS::Server::Request::Initialize;
2              
3 11     11   80 use strict;
  11         42  
  11         468  
4 11     11   51 use warnings;
  11         22  
  11         455  
5              
6 11     11   48 use parent 'PLS::Server::Request';
  11         103  
  11         58  
7              
8 11     11   1142 use PPI::Document;
  11         22  
  11         577  
9 11     11   42 use URI;
  11         22  
  11         180  
10              
11 11     11   39 use PLS::Parser::Document;
  11         14  
  11         219  
12 11     11   39 use PLS::Parser::Index;
  11         15  
  11         228  
13 11     11   1309936 use PLS::Server::Response::InitializeResult;
  11         34  
  11         594  
14 11     11   153 use PLS::Server::State;
  11         23  
  11         2569  
15              
16             =head1 NAME
17              
18             PLS::Server::Request::Initialize
19              
20             =head1 DESCRIPTION
21              
22             This is the first request from the client to the server.
23              
24             The client provides information about itself, and the server performs
25             some initialization for itself and returns its capabilities.
26              
27             =cut
28              
29             sub service
30             {
31 5     5 0 18 my ($self) = @_;
32              
33 5         73 my $root_uri = $self->{params}{rootUri};
34 5         23 my $workspace_folders = $self->{params}{workspaceFolders};
35 5 50       117 $workspace_folders = [] if (ref $workspace_folders ne 'ARRAY');
36 5         84 @{$workspace_folders} = map { $_->{uri} } @{$workspace_folders};
  5         75  
  5         229  
  5         39  
37 5 50 33     15 push @{$workspace_folders}, $root_uri if (not scalar @{$workspace_folders} and length $root_uri);
  0         0  
  5         298  
38 5         39 @{$workspace_folders} = map { $_->file } grep { $_->can('file') } map { URI->new($_) } @{$workspace_folders};
  5         5877  
  5         265  
  5         1726  
  5         329  
  5         49  
39              
40             # Create and cache index object
41 5         114 PLS::Parser::Index->new(workspace_folders => $workspace_folders);
42              
43 5         84 $PLS::Server::State::CLIENT_CAPABILITIES = $self->{params}{capabilities};
44              
45 5         327 return PLS::Server::Response::InitializeResult->new($self);
46             } ## end sub service
47              
48             1;