File Coverage

blib/lib/PLS/Server/Request/Initialize.pm
Criterion Covered Total %
statement 44 45 97.7
branch 2 4 50.0
condition 1 3 33.3
subroutine 10 10 100.0
pod 0 1 0.0
total 57 63 90.4


line stmt bran cond sub pod time code
1             package PLS::Server::Request::Initialize;
2              
3 9     9   68 use strict;
  9         19  
  9         210  
4 9     9   45 use warnings;
  9         18  
  9         182  
5              
6 9     9   57 use parent 'PLS::Server::Request';
  9         10  
  9         45  
7              
8 9     9   691 use PPI::Document;
  9         18  
  9         293  
9 9     9   45 use URI;
  9         9  
  9         257  
10              
11 9     9   45 use PLS::Parser::Document;
  9         17  
  9         249  
12 9     9   46 use PLS::Parser::Index;
  9         10  
  9         227  
13 9     9   3166 use PLS::Server::Response::InitializeResult;
  9         26  
  9         235  
14 9     9   46 use PLS::Server::State;
  9         18  
  9         1380  
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 57 my ($self) = @_;
32              
33 5         53 my $root_uri = $self->{params}{rootUri};
34 5         32 my $workspace_folders = $self->{params}{workspaceFolders};
35 5 50       34 $workspace_folders = [] if (ref $workspace_folders ne 'ARRAY');
36 5         40 @{$workspace_folders} = map { $_->{uri} } @{$workspace_folders};
  5         62  
  5         68  
  5         45  
37 5 50 33     49 push @{$workspace_folders}, $root_uri if (not scalar @{$workspace_folders} and length $root_uri);
  0         0  
  5         41  
38 5         13 @{$workspace_folders} = map { URI->new($_)->file } @{$workspace_folders};
  5         5550  
  5         161  
  5         20  
39              
40             # Create and cache index object
41 5         125 PLS::Parser::Index->new(workspace_folders => $workspace_folders);
42              
43 5         81 $PLS::Server::State::CLIENT_CAPABILITIES = $self->{params}{capabilities};
44              
45 5         162 return PLS::Server::Response::InitializeResult->new($self);
46             } ## end sub service
47              
48             1;