| 1 | package PLS::Server::Request::Workspace::Configuration; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use parent 'PLS::Server::Request'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use List::Util; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use PLS::Parser::Document; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use PLS::Parser::Index; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use PLS::Parser::PackageSymbols; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 9 | ▶ | use PLS::Parser::Pod; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 9 | ▶ | use PLS::Server::Request::TextDocument::PublishDiagnostics; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | 9 | ▶ | use PLS::Server::State; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | PLS::Server::Request::Workspace::Configuration | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | This is a message from the server to the client requesting that it send | ||||||||||||||||||||||||||||||||
| 25 | the values of some configuration items. | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | PLS requests all configuration starting with C<pls.>. | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | This class also handles the response from the client which stores the configuration | ||||||||||||||||||||||||||||||||
| 30 | in memory. | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | sub new | ||||||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||||||
| 36 | 5 | ▶ | my ($class) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 5 | return bless { | |||||||||||||||||||||||||||||||
| 39 | id => undef, # assigned by the server | ||||||||||||||||||||||||||||||||
| 40 | method => 'workspace/configuration', | ||||||||||||||||||||||||||||||||
| 41 | params => { | ||||||||||||||||||||||||||||||||
| 42 | items => [{section => 'perl'}, {section => 'pls'}] | ||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | }, $class; | ||||||||||||||||||||||||||||||||
| 45 | } ## end sub new | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | sub handle_response | ||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | my ($self, $response, $server) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
handle_response: called CC=17 SCAR=35.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 3 | ▶ | return if (Scalar::Util::reftype($response) ne 'HASH' or ref $response->{result} ne 'ARRAY'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::reftype($response) ne "HASH" or ref $response->{"result"} ne "ARRAY"
MC/DC0%0/2
builtin::reftype($response) ne "HASH" or ref $response->{"result"} ne "ARRAY"
builtin::reftype($response) ne "HASH"
ref $response->{"result"} ne "ARRAY"
Truth table33%1/3
A or B
A= builtin::reftype($response) ne "HASH"B= ref $response->{"result"} ne "ARRAY"
| |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 3 | my $config = {}; | |||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 3 | foreach my $result (@{$response->{result}}) | |||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | next if (ref $result ne 'HASH'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 3 | foreach my $key (keys %{$result}) | |||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||
| 61 | 21 | ▶ | $config->{$key} = $result->{$key} unless (exists $config->{$key}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | } ## end foreach my $result (@{$response...}) | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 3 | convert_config($config); | |||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 3 | my $index = PLS::Parser::Index->new(); | |||||||||||||||||||||||||||||||
| 68 | 3 | my @inc; | |||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | # Replace $ROOT_PATH with actual workspace paths in inc | ||||||||||||||||||||||||||||||||
| 71 | 3 | ▶ | if (exists $config->{inc} and ref $config->{inc} eq 'ARRAY') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/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 table33%1/3
A and B
A= exists $config->{"inc"}B= ref $config->{"inc"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||||||
| 73 | 3 | foreach my $inc (@{$config->{inc}}) | |||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||
| 75 | 0 | foreach my $folder (@{$index->workspace_folders}) | |||||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||||||
| 77 | 0 | my $interpolated = $inc =~ s/\$ROOT_PATH/$folder/gr; | |||||||||||||||||||||||||||||||
| 78 | 0 | push @inc, $interpolated; | |||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | } ## end foreach my $inc (@{$config->...}) | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 3 | $config->{inc} = [List::Util::uniq sort @inc]; | |||||||||||||||||||||||||||||||
| 83 | } ## end if (exists $config->{inc...}) | ||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 3 | ▶ | if (exists $config->{syntax}{perl} and length $config->{syntax}{perl}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $config->{"syntax"}{"perl"} and length $config->{"syntax"}{"perl"}
MC/DC0%0/2
exists $config->{"syntax"}{"perl"} and length $config->{"syntax"}{"perl"}
exists $config->{"syntax"}{"perl"}
length $config->{"syntax"}{"perl"}
Truth table33%1/3
A and B
A= exists $config->{"syntax"}{"perl"}B= length $config->{"syntax"}{"perl"}
| |||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||
| 87 | 0 | PLS::Parser::Pod->set_perl_exe($config->{syntax}{perl}); | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 3 | ▶ | if (exists $config->{syntax}{args} and ref $config->{syntax}{args} eq 'ARRAY' and scalar @{$config->{syntax}{args}}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
exists $config->{"syntax"}{"args"} and ref $config->{"syntax"}{"args"} eq "ARRAY" and scalar @{$config->{"syntax"}{"args"};}
exists $config->{"syntax"}{"args"} and ref $config->{"syntax"}{"args"} eq "ARRAY"
MC/DC0%0/2
exists $config->{"syntax"}{"args"} and ref $config->{"syntax"}{"args"} eq "ARRAY" and scalar @{$config->{"syntax"}{"args"};}
exists $config->{"syntax"}{"args"}
ref $config->{"syntax"}{"args"} eq "ARRAY"
Truth table33%1/3
A and B
A= exists $config->{"syntax"}{"args"}B= ref $config->{"syntax"}{"args"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||||||
| 92 | 0 | PLS::Parser::Pod->set_perl_args($config->{syntax}{args}); | |||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 3 | $PLS::Server::State::CONFIG = $config; | |||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | # @INC may have changed - republish diagnostics | ||||||||||||||||||||||||||||||||
| 98 | 3 | foreach my $uri (@{PLS::Parser::Document->open_files()}) | |||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||
| 100 | 0 | $server->send_server_request(PLS::Server::Request::TextDocument::PublishDiagnostics->new(uri => $uri)); | |||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 3 | PLS::Parser::PackageSymbols::start_package_symbols_process($config); | |||||||||||||||||||||||||||||||
| 104 | 3 | PLS::Parser::PackageSymbols::start_imported_package_symbols_process($config); | |||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 3 | return; | |||||||||||||||||||||||||||||||
| 107 | } ## end sub handle_response | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | sub convert_config | ||||||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | my ($config) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
convert_config: called CC=8 SCAR=24.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | 3 | ▶ | if (length $config->{pls}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | $config->{cmd} = $config->{pls} unless (length $config->{cmd}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 116 | 3 | delete $config->{pls}; | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | if (ref $config->{plsargs} eq 'ARRAY') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $config->{args} = $config->{plsargs} if (ref $config->{args} ne 'ARRAY'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 122 | 0 | delete $config->{plsargs}; | |||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 3 | ▶ | $config->{perltidy} = {} if (ref $config->{perltidy} ne 'HASH'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 3 | ▶ | if (length $config->{perltidyrc}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||
| 129 | 3 | ▶ | $config->{perltidy}{perltidyrc} = $config->{perltidyrc} unless (length $config->{perltidy}{perltidyrc}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | 3 | delete $config->{perltidyrc}; | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | 3 | return; | |||||||||||||||||||||||||||||||
| 134 | } ## end sub convert_config | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 9 | 1; | |||||||||||||||||||||||||||||||