| 1 | package PLS::Server::Request::Workspace::Configuration; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use parent 'PLS::Server::Request'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Coro; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use PLS::Parser::Document; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use PLS::Server::State; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use PLS::Server::Request::Diagnostics::PublishDiagnostics; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | PLS::Server::Request::Workspace::Configuration | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | This is a message from the server to the client requesting that it send | ||||||||||||||||||||||||||||
| 22 | the values of some configuration items. | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | PLS requests all configuration starting with C<perl.>. | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | This class also handles the response from the client which stores the configuration | ||||||||||||||||||||||||||||
| 27 | in memory. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub new | ||||||||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my ($class) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | return bless { | |||||||||||||||||||||||||||
| 36 | id => undef, # assigned by the server | ||||||||||||||||||||||||||||
| 37 | method => 'workspace/configuration', | ||||||||||||||||||||||||||||
| 38 | params => { | ||||||||||||||||||||||||||||
| 39 | items => [{section => 'perl'}] | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | }, $class; | ||||||||||||||||||||||||||||
| 42 | } ## end sub new | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub handle_response | ||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my ($self, $response, $server) = @_; | ||||||||||||||||||||||||||
|
Subroutine
handle_response: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return unless (Scalar::Util::reftype $response eq 'HASH' and ref $response->{result} eq 'ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::reftype($response) eq "HASH" and ref $response->{"result"} eq "ARRAY"
MC/DC0%0/2
builtin::reftype($response) eq "HASH" and ref $response->{"result"} eq "ARRAY"
builtin::reftype($response) eq "HASH"
ref $response->{"result"} eq "ARRAY"
Truth table0%0/3
A and B
A= builtin::reftype($response) eq "HASH"B= ref $response->{"result"} eq "ARRAY"
| |||||||||||||||||||||||||||||
| 49 | 0 | my $config = $response->{result}[0]; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | return unless (ref $config eq 'HASH'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | # Replace $ROOT_PATH with actual workspace root in inc | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (exists $config->{inc} and ref $config->{inc} eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $config->{"inc"} and ref $config->{"inc"} eq "ARRAY"
MC/DC0%0/2
exists $config->{"inc"} and ref $config->{"inc"} eq "ARRAY"
exists $config->{"inc"}
ref $config->{"inc"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $config->{"inc"}B= ref $config->{"inc"} eq "ARRAY"
| |||||||||||||||||||||||||||||
| 54 | { | ||||||||||||||||||||||||||||
| 55 | 0 | foreach my $inc (@{$config->{inc}}) | |||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||
| 57 | 0 | $inc =~ s/\$ROOT_PATH/$PLS::Server::State::ROOT_PATH/g; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } ## end if (exists $config->{inc...}) | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (exists $config->{cwd} and length $config->{cwd}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $config->{"cwd"} and length $config->{"cwd"}
MC/DC0%0/2
exists $config->{"cwd"} and length $config->{"cwd"}
exists $config->{"cwd"}
length $config->{"cwd"}
Truth table0%0/3
A and B
A= exists $config->{"cwd"}B= length $config->{"cwd"}
| |||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | 0 | $config->{cwd} =~ s/\$ROOT_PATH/$PLS::Server::State::ROOT_PATH/g; | |||||||||||||||||||||||||||
| 64 | 0 | chdir $config->{cwd}; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | $PLS::Server::State::CONFIG = $config; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # @INC may have changed - republish diagnostics | ||||||||||||||||||||||||||||
| 70 | 0 | foreach my $uri (@{PLS::Parser::Document->open_files()}) | |||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||
| 72 | 0 | $server->{server_requests}->put(PLS::Server::Request::Diagnostics::PublishDiagnostics->new(uri => $uri)); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||
| 76 | } ## end sub handle_response | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | 1; | |||||||||||||||||||||||||||