« blib/lib/PLS/Server/Request/Workspace/ExecuteCommand.pm
↑ Summary
blib/lib/PLS/Server/Request/TextDocument/DidChange.pm »
| 1 | package PLS::Server::Method::ServerMethod; | ||||||||||
| 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 PLS::Server::State; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 13 | ▶ | use PLS::Server::Request::Initialize; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 13 | ▶ | use PLS::Server::Request::Initialized; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 13 | ▶ | use PLS::Server::Request::CancelRequest; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 13 | ▶ | use PLS::Server::Request::Shutdown; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 13 | ▶ | use PLS::Server::Request::Exit; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 13 | ▶ | use PLS::Server::Response::ServerNotInitialized; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 13 | ▶ | use PLS::Server::Response::InvalidRequest; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | =head1 NAME | ||||||||||
| 16 | |||||||||||
| 17 | PLS::Server::Method::ServerMethod | ||||||||||
| 18 | |||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||
| 20 | |||||||||||
| 21 | This module redirects requests that the server must handle to the appropriate | ||||||||||
| 22 | subclass of L<PLS::Server::Request>. | ||||||||||
| 23 | |||||||||||
| 24 | It will also return the appropriate error if the client is attempting to make a | ||||||||||
| 25 | request before the server has been initialized (L<PLS::Server::Response::ServerNotInitialized>). | ||||||||||
| 26 | |||||||||||
| 27 | If a shutdown request has been sent and another request is sent that is not an exit | ||||||||||
| 28 | request, the appropriate error will be returned (L<PLS::Server::Response::InvalidRequest>). | ||||||||||
| 29 | |||||||||||
| 30 | Requests currently implemented: | ||||||||||
| 31 | |||||||||||
| 32 | =over | ||||||||||
| 33 | |||||||||||
| 34 | =item initialize - L<https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize> | ||||||||||
| 35 | |||||||||||
| 36 | L<PLS::Server::Request::Initialize> | ||||||||||
| 37 | |||||||||||
| 38 | =item initialized - L<https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialized> | ||||||||||
| 39 | |||||||||||
| 40 | L<PLS::Server::Request::Initialized> | ||||||||||
| 41 | |||||||||||
| 42 | =item $/cancelRequest - L<https://microsoft.github.io/language-server-protocol/specifications/specification-current/#cancelRequest> | ||||||||||
| 43 | |||||||||||
| 44 | L<PLS::Server::Request::CancelRequest> | ||||||||||
| 45 | |||||||||||
| 46 | =item shutdown - L<https://microsoft.github.io/language-server-protocol/specifications/specification-current/#shutdown> | ||||||||||
| 47 | |||||||||||
| 48 | L<PLS::Server::Request::Shutdown> | ||||||||||
| 49 | |||||||||||
| 50 | =item exit - L<https://microsoft.github.io/language-server-protocol/specifications/specification-current/#exit> | ||||||||||
| 51 | |||||||||||
| 52 | L<PLS::Server::Request::Exit> | ||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | =back | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||
| 58 | |||||||||||
| 59 | sub get_request | ||||||||||
| 60 | 16 | ▶ | { | ||||||||
|
Subroutine
get_request: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||
| 61 | 16 | my ($request) = @_; | |||||||||
| 62 | |||||||||||
| 63 | 16 | my $method = $request->{method}; | |||||||||
| 64 | |||||||||||
| 65 | 16 | ▶ | if ($method eq 'exit') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | { | ||||||||||
| 67 | 2 | return PLS::Server::Request::Exit->new($request); | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 14 | ▶ | return PLS::Server::Response::InvalidRequest->new($request) if $PLS::Server::State::SHUTDOWN; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | |||||||||||
| 72 | 13 | ▶ | if ($method eq 'initialize') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | { | ||||||||||
| 74 | 5 | return PLS::Server::Request::Initialize->new($request); | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 8 | ▶ | return PLS::Server::Response::ServerNotInitialized->new($request) unless $PLS::Server::State::INITIALIZED; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | |||||||||||
| 79 | 7 | ▶ | if ($method eq 'initialized') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | { | ||||||||||
| 81 | 5 | return PLS::Server::Request::Initialized->new($request); | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 2 | ▶ | if ($method eq '$/cancelRequest') ## no critic (RequireInterpolationOfMetachars) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | { | ||||||||||
| 86 | 1 | return PLS::Server::Request::CancelRequest->new($request); | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 1 | ▶ | if ($method eq 'shutdown') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | { | ||||||||||
| 91 | 1 | return PLS::Server::Request::Shutdown->new($request); | |||||||||
| 92 | } | ||||||||||
| 93 | |||||||||||
| 94 | 0 | return; | |||||||||
| 95 | } ## end sub get_request | ||||||||||
| 96 | |||||||||||
| 97 | sub is_server_method | ||||||||||
| 98 | 19 | ▶ | { | ||||||||
|
Subroutine
is_server_method: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||
| 99 | 19 | my ($method) = @_; | |||||||||
| 100 | |||||||||||
| 101 | 19 | ▶ | return 1 if ($method eq 'initialize'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | 14 | ▶ | return 1 if ($method eq 'initialized'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | 8 | ▶ | return 1 if ($method eq 'shutdown'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 7 | ▶ | return 1 if ($method eq 'exit'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | 5 | ▶ | return 1 if ($method eq '$'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 4 | return 0; | |||||||||
| 107 | } ## end sub is_server_method | ||||||||||
| 108 | |||||||||||
| 109 | 13 | 1; | |||||||||