1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
package Perl::LanguageServer::Methods ;
use Moose::Role ;
use JSON ;
use Data::Dump qw{pp} ;
no warnings 'uninitialized' ;
# ---------------------------------------------------------------------------
sub _rpcreq_initialize
{
my ($self, $workspace, $req) = @_ ;
#print STDERR "Call initialize\n" ;
$self -> logger ("initialize ", $Perl::LanguageServer::jsonpretty -> encode ($req -> params), "\n")
if ($Perl::LanguageServer::debug1) ;
$Perl::LanguageServer::workspace = Perl::LanguageServer::Workspace -> new ({ config => $req -> params }) ;
my $caps =
{
# Defines how text documents are synced. Is either a detailed structure defining each notification or
# for backwards compatibility the TextDocumentSyncKind number. If omitted it defaults to `TextDocumentSyncKind.None`.
textDocumentSync => 1, # full
# The server provides hover support.
#hoverProvider?: boolean;
# The server provides completion support.
#completionProvider?: CompletionOptions;
# The server provides signature help support.
#signatureHelpProvider?: SignatureHelpOptions;
signatureHelpProvider =>
{
triggerCharacters => ['('],
},
# The server provides goto definition support.
#definitionProvider?: boolean;
definitionProvider => JSON::true,
# The server provides Goto Type Definition support.
# Since 3.6.0
#typeDefinitionProvider?: boolean | (TextDocumentRegistrationOptions & StaticRegistrationOptions);
# The server provides Goto Implementation support.
# Since 3.6.0
#implementationProvider?: boolean | (TextDocumentRegistrationOptions & StaticRegistrationOptions);
# The server provides find references support.
referencesProvider => JSON::true,
# The server provides document highlight support.
#documentHighlightProvider?: boolean;
# The server provides document symbol support.
#documentSymbolProvider?: boolean;
documentSymbolProvider => JSON::true,
# The server provides workspace symbol support.
workspaceSymbolProvider => JSON::true,
# The server provides code actions.
#codeActionProvider?: boolean;
# The server provides code lens.
#codeLensProvider?: CodeLensOptions;
# The server provides document formatting.
#documentFormattingProvider?: boolean;
#documentFormattingProvider => JSON::true,
# The server provides document range formatting.
#documentRangeFormattingProvider?: boolean;
documentRangeFormattingProvider => JSON::true,
# The server provides document formatting on typing.
#documentOnTypeFormattingProvider?: DocumentOnTypeFormattingOptions;
# The server provides rename support.
#renameProvider?: boolean;
# The server provides document link support.
#documentLinkProvider?: DocumentLinkOptions;
# The server provides color provider support.
# Since 3.6.0
#colorProvider?: boolean | ColorProviderOptions | (ColorProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions);
# The server provides execute command support.
#executeCommandProvider?: ExecuteCommandOptions;
# The server provides selection range support.
# @since 3.15.0
# selectionRangeProvider?: boolean | SelectionRangeOptions | SelectionRangeRegistrationOptions;
#selectionRangeProvider => JSON::true,
# Workspace specific server capabilities
workspace => {
# The server supports workspace folder.
# Since 3.6.0
workspaceFolders => {
# The server has support for workspace folders
supported => JSON::true,
# * Whether the server wants to receive workspace folder
# * change notifications.
# *
# * If a strings is provided the string is treated as a ID
# * under which the notification is registered on the client
# * side. The ID can be used to unregister for these events
# * using the `client/unregisterCapability` request.
# */
changeNotifications => JSON::true,
}
}
# Experimental server capabilities.
#experimental?: any;
} ;
return { capabilities => $caps } ;
}
# ---------------------------------------------------------------------------
sub _rpcnot_initialized
{
my ($self, $workspace, $req) = @_ ;
return if (!$Perl::LanguageServer::client_version) ;
if ($Perl::LanguageServer::client_version ne $Perl::LanguageServer::VERSION)
{
my $msg = "Version of IDE/Editor plugin is $Perl::LanguageServer::client_version\nVersion of Perl::LanguageServer is $Perl::LanguageServer::VERSION\nPlease make sure you run matching versions of the plugin and the Perl::LanguageServer module\nUse 'cpan Perl::LanguageServer' to install the newest version of the Perl::LanguageServer module\n" ;
$self -> logger ("\n$msg\n") ;
}
return ;
}
# ---------------------------------------------------------------------------
sub _rpcnot_cancelRequest
{
my ($self, $workspace, $req) = @_ ;
my $cancel_id = $req -> params -> {id} ;
return if (!$cancel_id) ;
return if (!exists $Perl::LanguageServer::running_req{$cancel_id}) ;
$Perl::LanguageServer::running_req{$cancel_id} -> cancel_req ;
return ;
}
# ---------------------------------------------------------------------------
sub _rpcreq_shutdown
{
my ($self, $workspace, $req) = @_ ;
return if (!$workspace) ;
$workspace -> shutdown ;
}
# ---------------------------------------------------------------------------
sub _rpcnot_exit
{
my ($self, $workspace, $req) = @_ ;
print STDERR "Exit\n" ;
exit (1) if (!$workspace) ;
exit (1) if (!$workspace -> is_shutdown) ;
exit (0) ;
return ;
}
# ---------------------------------------------------------------------------
1 ;
|