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