2019-05-02 13:56:57 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import os.path
|
|
|
|
|
from os.path import join
|
|
|
|
|
|
|
|
|
|
""" Script to generate the 'generated' parts of the code """
|
|
|
|
|
|
2019-05-03 15:55:40 -04:00
|
|
|
LSP_Messages_Generic_Header = """-- Automatically generated, do not edit.
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2020-01-03 19:50:42 +02:00
|
|
|
with Ada.Tags;
|
2019-07-24 12:55:51 +03:00
|
|
|
with LSP.Generic_{kind}s;
|
2020-01-03 19:50:42 +02:00
|
|
|
with LSP.JSON_Streams;
|
2019-08-02 18:07:17 +03:00
|
|
|
with LSP.Server_{kind}_Receivers;
|
|
|
|
|
use LSP.Server_{kind}_Receivers;
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2019-07-23 17:33:49 +03:00
|
|
|
package LSP.Messages.Server_{kind}s is
|
2019-08-02 18:07:17 +03:00
|
|
|
|
2021-07-11 23:38:23 +01:00
|
|
|
type Server_{kind} is abstract new LSP.Messages.{kind}Message{record};
|
2019-08-02 18:07:17 +03:00
|
|
|
|
2020-01-03 19:50:42 +02:00
|
|
|
function Decode
|
|
|
|
|
(JS : not null access LSP.JSON_Streams.JSON_Stream)
|
|
|
|
|
return Server_{kind} is abstract;
|
|
|
|
|
|
2019-08-02 18:07:17 +03:00
|
|
|
procedure Visit
|
|
|
|
|
(Self : Server_{kind};
|
|
|
|
|
Handler : access Server_{kind}_Receiver'Class) is abstract;
|
2020-01-03 19:50:42 +02:00
|
|
|
|
2021-06-22 22:21:45 +03:00
|
|
|
function Method_To_Tag
|
|
|
|
|
(Method : VSS.Strings.Virtual_String) return Ada.Tags.Tag;
|
2020-01-03 19:50:42 +02:00
|
|
|
-- For given LSP method return a corresponding message type tag
|
2019-05-12 13:39:55 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
C_Method_Function_Snippet = """
|
2019-09-11 14:02:28 +03:00
|
|
|
function On_{request_name}_Request
|
|
|
|
|
(Self : access Server_Request_Handler;
|
|
|
|
|
Request : LSP.Messages.Server_Requests.{request_name}_Request)
|
2020-09-16 12:25:46 +03:00
|
|
|
return LSP.Messages.Server_Responses.{response_name}
|
|
|
|
|
is abstract;
|
2019-05-12 13:39:55 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
C_Method_Procedure_Snippet = """
|
|
|
|
|
procedure On_{request_name}_{kind}
|
2019-08-02 18:07:17 +03:00
|
|
|
(Self : access Server_{kind}_Receiver;
|
2019-05-12 13:39:55 +02:00
|
|
|
Value : LSP.Messages.{params_name}) is abstract;
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
C_Method_Procedure_Snippet_Noparam = """
|
|
|
|
|
procedure On_{request_name}_{kind}
|
2019-08-02 18:07:17 +03:00
|
|
|
(Self : access Server_{kind}_Receiver) is abstract;
|
2019-05-02 13:56:57 -04:00
|
|
|
"""
|
|
|
|
|
|
2019-08-02 19:47:39 +03:00
|
|
|
C_Method_Request_Snippet = """
|
|
|
|
|
procedure On_{request_name}_{kind}
|
|
|
|
|
(Self : access Server_{kind}_Receiver;
|
|
|
|
|
Value : LSP.Messages.Server_{kind}s.{request_name}_{kind})
|
|
|
|
|
is abstract;
|
|
|
|
|
"""
|
|
|
|
|
|
2019-05-03 15:55:40 -04:00
|
|
|
LSP_Messages_Generic_Body_Header = """-- Automatically generated, do not edit.
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2019-07-23 17:33:49 +03:00
|
|
|
package body LSP.Messages.Server_{kind}s is
|
2019-07-30 20:48:20 +03:00
|
|
|
|
|
|
|
|
-- These messages are sent from client to server.
|
2020-01-03 19:50:42 +02:00
|
|
|
|
|
|
|
|
Map : Maps.Map;
|
|
|
|
|
|
|
|
|
|
function Method_To_Tag
|
2021-06-22 22:21:45 +03:00
|
|
|
(Method : VSS.Strings.Virtual_String) return Ada.Tags.Tag is
|
2020-01-03 19:50:42 +02:00
|
|
|
begin
|
|
|
|
|
return Method_To_Tag (Map, Method);
|
|
|
|
|
end Method_To_Tag;
|
2019-07-23 15:03:09 +03:00
|
|
|
"""
|
|
|
|
|
|
2019-08-02 18:07:17 +03:00
|
|
|
C_Method_Visit_Body_Snippet = """
|
|
|
|
|
overriding procedure Visit
|
|
|
|
|
(Self : {request_name}_{kind};
|
|
|
|
|
Handler : access Server_{kind}_Receiver'Class) is
|
|
|
|
|
begin
|
2019-08-02 19:47:39 +03:00
|
|
|
Handler.On_{request_name}_{kind} (Self{params});
|
2019-08-02 18:07:17 +03:00
|
|
|
end Visit;
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
C_Method_Visit_Body_Snippet_Noparams = """
|
|
|
|
|
overriding procedure Visit
|
|
|
|
|
(Self : {request_name}_{kind};
|
|
|
|
|
Handler : access Server_{kind}_Receiver'Class)
|
|
|
|
|
is
|
|
|
|
|
pragma Unreferenced (Self);
|
|
|
|
|
begin
|
|
|
|
|
Handler.On_{request_name}_{kind};
|
|
|
|
|
end Visit;
|
|
|
|
|
"""
|
|
|
|
|
|
2020-01-03 19:50:42 +02:00
|
|
|
C_Method_Decode_Body_Snippet = """
|
|
|
|
|
overriding function Decode
|
|
|
|
|
(JS : not null access LSP.JSON_Streams.JSON_Stream)
|
|
|
|
|
return {request_name}_{kind} is
|
|
|
|
|
begin
|
|
|
|
|
return V : {request_name}_{kind} do
|
2020-09-16 12:25:46 +03:00
|
|
|
{kind}Message'Read (JS, {kind}Message (V));
|
2020-01-03 19:50:42 +02:00
|
|
|
end return;
|
|
|
|
|
end Decode;
|
2019-05-02 13:56:57 -04:00
|
|
|
"""
|
|
|
|
|
|
2019-07-23 14:12:39 +03:00
|
|
|
C_Handler_Procedure_Body = """-- Automatically generated, do not edit.
|
|
|
|
|
|
2019-07-23 17:33:49 +03:00
|
|
|
with LSP.Messages.Server_Notifications; use LSP.Messages.Server_Notifications;
|
2019-07-23 14:12:39 +03:00
|
|
|
|
|
|
|
|
procedure LSP.Servers.Handle_{kind}
|
2019-07-23 17:10:31 +03:00
|
|
|
(Self : not null LSP.Server_Notification_Handlers
|
2019-07-23 14:12:39 +03:00
|
|
|
.Server_Notification_Handler_Access;
|
|
|
|
|
{kind} : LSP.Messages.{kind}Message'Class) is
|
|
|
|
|
begin
|
2019-05-12 13:39:55 +02:00
|
|
|
{handler_snippets}
|
2019-07-23 14:12:39 +03:00
|
|
|
end LSP.Servers.Handle_{kind};
|
2019-05-12 13:39:55 +02:00
|
|
|
"""
|
|
|
|
|
|
2019-07-23 14:12:39 +03:00
|
|
|
C_Handler_Function_Body = """-- Automatically generated, do not edit.
|
|
|
|
|
|
2019-07-23 17:33:49 +03:00
|
|
|
with LSP.Messages.Server_Requests; use LSP.Messages.Server_Requests;
|
2019-07-23 14:12:39 +03:00
|
|
|
|
|
|
|
|
function LSP.Servers.Handle_{kind}
|
2019-07-23 17:10:31 +03:00
|
|
|
(Self : not null Server_Request_Handlers
|
|
|
|
|
.Server_Request_Handler_Access;
|
2019-07-23 14:12:39 +03:00
|
|
|
{kind} : LSP.Messages.{kind}Message'Class)
|
2021-06-22 15:53:55 +03:00
|
|
|
return LSP.Messages.ResponseMessage'Class is
|
2019-07-23 14:12:39 +03:00
|
|
|
begin
|
2019-05-12 13:39:55 +02:00
|
|
|
{handler_snippets}
|
2019-07-23 14:12:39 +03:00
|
|
|
return LSP.Messages.ResponseMessage'
|
|
|
|
|
(Is_Error => True,
|
|
|
|
|
jsonrpc => <>,
|
|
|
|
|
id => <>,
|
|
|
|
|
error =>
|
|
|
|
|
(Is_Set => True,
|
|
|
|
|
Value =>
|
|
|
|
|
(code => LSP.Messages.MethodNotFound,
|
2021-06-22 14:41:08 +03:00
|
|
|
message => "The {kind} handler doesn't support this",
|
2019-07-23 14:12:39 +03:00
|
|
|
others => <>)));
|
|
|
|
|
end LSP.Servers.Handle_{kind};
|
2019-05-12 13:39:55 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
C_Handler_Snippet_Function = """
|
|
|
|
|
if {kind} in {request_name}_{kind}'Class then
|
|
|
|
|
declare
|
|
|
|
|
R : LSP.Messages.ResponseMessage'Class :=
|
|
|
|
|
Self.On_{request_name}_{kind}
|
2019-09-11 14:02:28 +03:00
|
|
|
({request_name}_{kind} ({kind}));
|
2019-05-12 13:39:55 +02:00
|
|
|
begin
|
2021-06-22 15:53:55 +03:00
|
|
|
R.jsonrpc := "2.0";
|
2019-05-12 13:39:55 +02:00
|
|
|
R.id := Request.id;
|
|
|
|
|
return R;
|
|
|
|
|
end;
|
|
|
|
|
end if;
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
C_Handler_Snippet_Procedure = """
|
|
|
|
|
if {kind} in {request_name}_{kind}'Class then
|
|
|
|
|
Self.On_{request_name}_{kind}
|
|
|
|
|
(({request_name}_{kind} ({kind}).params));
|
|
|
|
|
return;
|
|
|
|
|
end if;
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
C_Handler_Snippet_Procedure_Noparams = """
|
|
|
|
|
if {kind} in {request_name}_{kind}'Class then
|
|
|
|
|
Self.On_{request_name}_{kind};
|
|
|
|
|
return;
|
|
|
|
|
end if;
|
|
|
|
|
"""
|
|
|
|
|
|
2020-01-03 19:50:42 +02:00
|
|
|
LSP_Messages_Body_Begin = """
|
|
|
|
|
begin"""
|
|
|
|
|
|
|
|
|
|
LSP_Messages_Insert = """
|
|
|
|
|
|
|
|
|
|
Map.Insert
|
2021-06-22 14:41:08 +03:00
|
|
|
("{protocol_name}",
|
2020-01-03 19:50:42 +02:00
|
|
|
{request_name}_{kind}'Tag);"""
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2019-05-03 15:55:40 -04:00
|
|
|
LSP_Messages_Generic_Footer = """
|
2019-07-23 17:33:49 +03:00
|
|
|
end LSP.Messages.Server_{kind}s;
|
2019-05-02 13:56:57 -04:00
|
|
|
"""
|
|
|
|
|
|
2019-05-03 15:55:40 -04:00
|
|
|
LSP_Messages_Generic_Type_Snippet = """
|
2019-07-24 12:55:51 +03:00
|
|
|
package {request_name}_{kind}s is
|
2019-08-02 18:07:17 +03:00
|
|
|
new LSP.Generic_{kind}s
|
|
|
|
|
(Server_{kind},
|
2020-01-03 19:50:42 +02:00
|
|
|
{params_name},
|
|
|
|
|
Server_{kind}_Receiver'Class);
|
2019-07-24 12:55:51 +03:00
|
|
|
|
|
|
|
|
type {request_name}_{kind} is
|
|
|
|
|
new {request_name}_{kind}s.{kind} with null record;
|
2019-08-02 18:07:17 +03:00
|
|
|
|
|
|
|
|
overriding procedure Visit
|
|
|
|
|
(Self : {request_name}_{kind};
|
2019-08-02 19:47:39 +03:00
|
|
|
Handler : access Server_{kind}_Receiver'Class);
|
2019-05-02 13:56:57 -04:00
|
|
|
"""
|
|
|
|
|
|
2019-05-03 15:55:40 -04:00
|
|
|
LSP_Messages_Generic_Type_Snippet_Noparams = """
|
2019-08-02 18:07:17 +03:00
|
|
|
type {request_name}_{kind} is new Server_{kind} with null record;
|
2019-05-02 16:42:59 -04:00
|
|
|
|
2020-01-03 19:50:42 +02:00
|
|
|
overriding function Decode
|
|
|
|
|
(JS : not null access LSP.JSON_Streams.JSON_Stream)
|
|
|
|
|
return {request_name}_{kind};
|
|
|
|
|
|
2019-08-02 18:07:17 +03:00
|
|
|
overriding procedure Visit
|
|
|
|
|
(Self : {request_name}_{kind};
|
2019-08-02 19:47:39 +03:00
|
|
|
Handler : access Server_{kind}_Receiver'Class);
|
2019-05-02 13:56:57 -04:00
|
|
|
"""
|
|
|
|
|
|
2019-07-23 17:10:31 +03:00
|
|
|
LSP_Server_Handlers_Header = """-- Automatically generated, do not edit.
|
|
|
|
|
|
2021-11-16 17:49:52 +00:00
|
|
|
pragma Style_Checks (Off);
|
|
|
|
|
|
2019-09-11 14:02:28 +03:00
|
|
|
with LSP.Messages.Server_Requests;
|
|
|
|
|
with LSP.Messages.Server_Responses;
|
2019-07-23 17:10:31 +03:00
|
|
|
|
2019-09-11 14:02:28 +03:00
|
|
|
package LSP.Server_Request_{handler}s is
|
2019-07-23 17:10:31 +03:00
|
|
|
|
2019-09-11 14:02:28 +03:00
|
|
|
type Server_Request_{handler} is limited interface;
|
|
|
|
|
type Server_Request_{handler}_Access is
|
|
|
|
|
access all Server_Request_{handler}'Class;
|
2019-07-23 17:10:31 +03:00
|
|
|
-- A type which represents a handler which supports reacting
|
2019-09-11 14:02:28 +03:00
|
|
|
-- to Requests. Clients implementing this interface should override
|
|
|
|
|
-- the *_Request methods, and clients making use of this interface
|
|
|
|
|
-- should simply call Handle_Request when they want to dispatch
|
|
|
|
|
-- a Request to the handler.
|
2019-07-23 17:10:31 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
LSP_Server_Handlers_Footer = """
|
2019-08-02 18:07:17 +03:00
|
|
|
end LSP.Server_{kind}_{handler}s;
|
2019-07-23 17:10:31 +03:00
|
|
|
"""
|
|
|
|
|
|
2019-08-02 19:47:39 +03:00
|
|
|
LSP_Server_Recievers_Header = """-- Automatically generated, do not edit.
|
|
|
|
|
|
2019-09-11 14:02:28 +03:00
|
|
|
limited with LSP.Messages{extra_with};
|
2019-08-02 19:47:39 +03:00
|
|
|
|
|
|
|
|
package LSP.Server_{kind}_{handler}s is
|
|
|
|
|
|
|
|
|
|
type Server_{kind}_{handler} is limited interface;
|
2019-09-11 14:02:28 +03:00
|
|
|
type Server_{kind}_{handler}_Access is
|
|
|
|
|
access all Server_{kind}_{handler}'Class;
|
2019-09-12 14:06:20 +03:00
|
|
|
-- A type which represents a handler which supports reacting
|
|
|
|
|
-- to {kind}s. Clients implementing this interface should override
|
|
|
|
|
-- the *_{kind} methods, and clients making use of this interface
|
|
|
|
|
-- should simply call corresponding method when they want to dispatch
|
|
|
|
|
-- a {kind} to the handler.
|
2019-08-02 19:47:39 +03:00
|
|
|
"""
|
|
|
|
|
|
2019-05-02 13:56:57 -04:00
|
|
|
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
REQUESTS = [
|
2019-05-12 13:39:55 +02:00
|
|
|
('initialize', 'Initialize', 'InitializeParams', 'Initialize_Response'),
|
2019-07-30 20:48:20 +03:00
|
|
|
('shutdown', 'Shutdown', None, 'Shutdown_Response'),
|
2019-05-12 13:39:55 +02:00
|
|
|
('textDocument/codeAction', 'CodeAction', 'CodeActionParams',
|
|
|
|
|
'CodeAction_Response'),
|
|
|
|
|
('textDocument/completion', 'Completion', 'TextDocumentPositionParams',
|
|
|
|
|
'Completion_Response'),
|
2021-09-06 13:19:44 +02:00
|
|
|
('completionItem/resolve', 'CompletionItemResolve', 'CompletionItem',
|
|
|
|
|
'CompletionItemResolve_Response'),
|
2020-10-12 13:48:24 +03:00
|
|
|
('textDocument/definition', 'Definition', 'DefinitionParams',
|
2020-01-14 16:55:11 +02:00
|
|
|
'Location_Link_Response'),
|
2020-10-12 13:48:24 +03:00
|
|
|
('textDocument/declaration', 'Declaration', 'DeclarationParams',
|
2020-01-14 16:55:11 +02:00
|
|
|
'Location_Link_Response'),
|
2019-12-18 13:30:30 -05:00
|
|
|
('textDocument/implementation', 'Implementation',
|
2020-10-12 13:48:24 +03:00
|
|
|
'ImplementationParams', 'Location_Link_Response'),
|
2019-06-11 14:24:20 +02:00
|
|
|
('textDocument/typeDefinition', 'Type_Definition',
|
2020-01-14 16:55:11 +02:00
|
|
|
'TextDocumentPositionParams', 'Location_Link_Response'),
|
2020-11-20 16:35:30 +01:00
|
|
|
('textDocument/documentHighlight', 'Highlight', 'TextDocumentPositionParams',
|
2019-05-12 13:39:55 +02:00
|
|
|
'Highlight_Response'),
|
|
|
|
|
('textDocument/hover', 'Hover', 'TextDocumentPositionParams',
|
|
|
|
|
'Hover_Response'),
|
2020-01-13 19:23:16 +02:00
|
|
|
('textDocument/documentLink', 'Document_Links',
|
|
|
|
|
'DocumentLinkParams', 'Links_Response'),
|
2019-05-12 13:39:55 +02:00
|
|
|
('textDocument/references', 'References', 'ReferenceParams',
|
|
|
|
|
'Location_Response'),
|
2019-05-02 13:56:57 -04:00
|
|
|
('textDocument/signatureHelp', 'Signature_Help',
|
2021-03-18 17:25:28 +01:00
|
|
|
'SignatureHelpParams', 'SignatureHelp_Response'),
|
2019-05-02 13:56:57 -04:00
|
|
|
('textDocument/documentSymbol', 'Document_Symbols',
|
2019-05-12 13:39:55 +02:00
|
|
|
'DocumentSymbolParams', 'Symbol_Response'),
|
2019-07-01 19:24:46 +03:00
|
|
|
('textDocument/rename', 'Rename', 'RenameParams', 'Rename_Response'),
|
2020-10-12 13:48:24 +03:00
|
|
|
('textDocument/prepareRename', 'Prepare_Rename',
|
|
|
|
|
'PrepareRenameParams', 'Prepare_Rename_Response'),
|
2019-05-12 13:39:55 +02:00
|
|
|
('textDocument/executeCommand', 'Execute_Command', 'ExecuteCommandParams',
|
|
|
|
|
'ExecuteCommand_Response'),
|
2020-01-15 16:38:37 +02:00
|
|
|
('textDocument/documentColor', 'Document_Color', 'DocumentColorParams',
|
|
|
|
|
'DocumentColor_Response'),
|
2020-01-15 17:01:58 +02:00
|
|
|
('textDocument/colorPresentation', 'Color_Presentation',
|
|
|
|
|
'ColorPresentationParams', 'ColorPresentation_Response'),
|
2020-01-15 18:28:41 +02:00
|
|
|
('textDocument/foldingRange', 'Folding_Range',
|
|
|
|
|
'FoldingRangeParams', 'FoldingRange_Response'),
|
2020-05-06 12:34:28 +03:00
|
|
|
('textDocument/formatting', 'Formatting',
|
|
|
|
|
'DocumentFormattingParams', 'Formatting_Response'),
|
|
|
|
|
('textDocument/rangeFormatting', 'Range_Formatting',
|
|
|
|
|
'DocumentRangeFormattingParams', 'Range_Formatting_Response'),
|
2023-06-13 15:54:47 +01:00
|
|
|
('textDocument/onTypeFormatting', 'On_Type_Formatting',
|
|
|
|
|
'DocumentOnTypeFormattingParams', 'On_Type_Formatting_Response'),
|
2020-03-20 17:04:29 +02:00
|
|
|
('textDocument/selectionRange', 'Selection_Range',
|
|
|
|
|
'SelectionRangeParams', 'SelectionRange_Response'),
|
2022-04-13 16:35:42 +03:00
|
|
|
('textDocument/semanticTokens/full', 'Document_Tokens_Full',
|
|
|
|
|
'SemanticTokensParams', 'SemanticTokens_Response'),
|
2022-05-10 16:42:42 +03:00
|
|
|
('textDocument/semanticTokens/range', 'Document_Tokens_Range',
|
|
|
|
|
'SemanticTokensRangeParams', 'SemanticTokens_Response'),
|
2020-09-16 12:56:13 +03:00
|
|
|
('textDocument/prepareCallHierarchy', 'Prepare_Call_Hierarchy',
|
|
|
|
|
'CallHierarchyPrepareParams', 'PrepareCallHierarchy_Response'),
|
2020-09-16 13:24:48 +03:00
|
|
|
('callHierarchy/incomingCalls', 'Incoming_Calls',
|
|
|
|
|
'CallHierarchyIncomingCallsParams', 'IncomingCalls_Response'),
|
2020-09-16 13:42:17 +03:00
|
|
|
('callHierarchy/outgoingCalls', 'Outgoing_Calls',
|
|
|
|
|
'CallHierarchyOutgoingCallsParams', 'OutgoingCalls_Response'),
|
2019-05-12 13:39:55 +02:00
|
|
|
('workspace/symbol', 'Workspace_Symbols', 'WorkspaceSymbolParams',
|
|
|
|
|
'Symbol_Response'),
|
2019-05-02 16:00:44 -04:00
|
|
|
('workspace/executeCommand', 'Workspace_Execute_Command',
|
2019-05-12 13:39:55 +02:00
|
|
|
'ExecuteCommandParams', 'ExecuteCommand_Response'),
|
2021-11-16 17:49:52 +00:00
|
|
|
('workspace/willCreateFiles', 'Workspace_Will_Create_Files',
|
|
|
|
|
'CreateFilesParams', 'WillCreateFiles_Response'),
|
|
|
|
|
('workspace/willRenameFiles', 'Workspace_Will_Rename_Files',
|
|
|
|
|
'RenameFilesParams', 'WillRenameFiles_Response'),
|
|
|
|
|
('workspace/willDeleteFiles', 'Workspace_Will_Delete_Files',
|
|
|
|
|
'DeleteFilesParams', 'WillDeleteFiles_Response'),
|
2019-06-03 21:23:23 -04:00
|
|
|
|
|
|
|
|
# ALS-specific requests
|
2020-06-09 10:43:02 +02:00
|
|
|
('textDocument/alsShowDependencies', 'ALS_Show_Dependencies',
|
|
|
|
|
'ALS_ShowDependenciesParams',
|
|
|
|
|
'ALS_ShowDependencies_Response'),
|
2022-06-08 16:57:42 +02:00
|
|
|
('workspace/alsSourceDirs', 'ALS_Source_Dirs',
|
|
|
|
|
None,
|
|
|
|
|
'ALS_SourceDirs_Response'),
|
2019-09-18 14:10:41 +03:00
|
|
|
('$/alsDebug', 'ALS_Debug', 'ALSDebugParams', 'ALS_Debug_Response'),
|
2021-07-11 23:38:23 +01:00
|
|
|
('$/alsCheckSyntax', 'ALS_Check_Syntax', 'ALS_Check_Syntax_Params',
|
|
|
|
|
'ALS_Check_Syntax_Response'),
|
2023-06-01 11:31:43 +01:00
|
|
|
('$/glsMains', 'GLS_Mains', None, 'GLS_Mains_Response'),
|
|
|
|
|
('$/glsExecutables', 'GLS_Executables', None, 'GLS_Executables_Response'),
|
|
|
|
|
('$/glsObjectDir', 'GLS_Object_Dir', None, 'GLS_Object_Dir_Response'),
|
|
|
|
|
('$/glsProjectFile', 'GLS_Project_File', None, 'GLS_Project_File_Response'),
|
2019-05-02 13:56:57 -04:00
|
|
|
]
|
2019-05-12 13:39:55 +02:00
|
|
|
# Names of requests in the form (protocol name, Ada name, parameter name,
|
|
|
|
|
# response name)
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2019-05-03 15:55:40 -04:00
|
|
|
NOTIFICATIONS = [
|
|
|
|
|
('initialized', 'Initialized', None),
|
|
|
|
|
('exit', 'Exit', None),
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2019-05-12 13:39:55 +02:00
|
|
|
('workspace/didChangeConfiguration', 'DidChangeConfiguration',
|
|
|
|
|
'DidChangeConfigurationParams'),
|
2020-01-14 19:29:44 +02:00
|
|
|
('workspace/didChangeWorkspaceFolders', 'DidChangeWorkspaceFolders',
|
|
|
|
|
'DidChangeWorkspaceFoldersParams'),
|
2020-11-03 10:20:42 +00:00
|
|
|
('workspace/didChangeWatchedFiles', 'DidChangeWatchedFiles',
|
|
|
|
|
'DidChangeWatchedFilesParams'),
|
2021-11-16 17:49:52 +00:00
|
|
|
('workspace/didCreateFiles', 'DidCreateFiles',
|
|
|
|
|
'CreateFilesParams'),
|
|
|
|
|
('workspace/didRenameFiles', 'DidRenameFiles',
|
|
|
|
|
'RenameFilesParams'),
|
|
|
|
|
('workspace/didDeleteFiles', 'DidDeleteFiles',
|
|
|
|
|
'DeleteFilesParams'),
|
|
|
|
|
|
2019-09-11 15:24:11 +03:00
|
|
|
('$/cancelRequest', 'Cancel', 'CancelParams'),
|
2023-03-20 15:53:59 +01:00
|
|
|
('$/setTrace', 'SetTrace', 'SetTraceParams'),
|
2019-05-03 15:55:40 -04:00
|
|
|
|
|
|
|
|
# TODO: rename these to TextDocumentDidOpen/DidChange/DidSave/DidClose?
|
|
|
|
|
('textDocument/didOpen', 'DidOpenTextDocument',
|
|
|
|
|
'DidOpenTextDocumentParams'),
|
|
|
|
|
('textDocument/didChange', 'DidChangeTextDocument',
|
|
|
|
|
'DidChangeTextDocumentParams'),
|
|
|
|
|
('textDocument/didSave', 'DidSaveTextDocument',
|
|
|
|
|
'DidSaveTextDocumentParams'),
|
|
|
|
|
('textDocument/didClose', 'DidCloseTextDocument',
|
|
|
|
|
'DidCloseTextDocumentParams'),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_message_types():
|
2019-05-02 13:56:57 -04:00
|
|
|
""" Write source/protocol/lsp-messages-request.* """
|
|
|
|
|
|
2021-07-11 23:38:23 +01:00
|
|
|
def write_package(data_array, kind, record, ads_name, handler_is_procedure):
|
2019-05-03 15:55:40 -04:00
|
|
|
"""Factorization function"""
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2019-05-03 15:55:40 -04:00
|
|
|
# Write the .ads
|
2020-09-13 11:37:00 +01:00
|
|
|
with open(ads_name, 'w') as ads:
|
2021-07-11 23:38:23 +01:00
|
|
|
ads.write(LSP_Messages_Generic_Header.format(kind=kind, record=record))
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2019-05-12 13:39:55 +02:00
|
|
|
for l in data_array:
|
|
|
|
|
request_name = l[1]
|
|
|
|
|
params_name = l[2]
|
2019-05-03 15:55:40 -04:00
|
|
|
if params_name:
|
|
|
|
|
ads.write(LSP_Messages_Generic_Type_Snippet.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
params_name=params_name,
|
|
|
|
|
kind=kind))
|
|
|
|
|
else:
|
|
|
|
|
ads.write(
|
|
|
|
|
LSP_Messages_Generic_Type_Snippet_Noparams.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
kind=kind))
|
|
|
|
|
|
|
|
|
|
ads.write(LSP_Messages_Generic_Footer.format(kind=kind))
|
2019-05-02 16:42:59 -04:00
|
|
|
|
2019-08-02 18:07:17 +03:00
|
|
|
def write_body(data_array, kind, adb_name, handler_is_procedure):
|
|
|
|
|
"""Factorization function"""
|
|
|
|
|
|
2020-01-03 19:50:42 +02:00
|
|
|
# Write the .adb
|
2020-09-13 11:37:00 +01:00
|
|
|
with open(adb_name, 'w') as adb:
|
2019-08-02 18:07:17 +03:00
|
|
|
adb.write(LSP_Messages_Generic_Body_Header.format(kind=kind))
|
|
|
|
|
|
|
|
|
|
for l in data_array:
|
|
|
|
|
request_name = l[1]
|
|
|
|
|
params_name = l[2]
|
2020-01-03 19:50:42 +02:00
|
|
|
|
|
|
|
|
if not params_name:
|
|
|
|
|
adb.write(
|
|
|
|
|
C_Method_Decode_Body_Snippet.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
kind=kind))
|
|
|
|
|
|
2019-08-02 19:47:39 +03:00
|
|
|
if params_name or not handler_is_procedure:
|
2019-08-02 18:07:17 +03:00
|
|
|
adb.write(
|
|
|
|
|
C_Method_Visit_Body_Snippet.format(
|
|
|
|
|
request_name=request_name,
|
2019-08-02 19:47:39 +03:00
|
|
|
kind=kind,
|
|
|
|
|
params=".params" if handler_is_procedure else ""))
|
2019-08-02 18:07:17 +03:00
|
|
|
else:
|
|
|
|
|
adb.write(
|
|
|
|
|
C_Method_Visit_Body_Snippet_Noparams.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
kind=kind))
|
|
|
|
|
|
2020-01-03 19:50:42 +02:00
|
|
|
adb.write(LSP_Messages_Body_Begin.format(kind=kind))
|
|
|
|
|
|
|
|
|
|
for l in data_array:
|
|
|
|
|
protocol_name = l[0]
|
|
|
|
|
request_name = l[1]
|
|
|
|
|
params_name = l[2]
|
|
|
|
|
adb.write(LSP_Messages_Insert.format(
|
|
|
|
|
protocol_name=protocol_name,
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
kind=kind))
|
|
|
|
|
|
2019-08-02 18:07:17 +03:00
|
|
|
adb.write(LSP_Messages_Generic_Footer.format(kind=kind))
|
|
|
|
|
|
2019-05-03 15:55:40 -04:00
|
|
|
gen_dir = join(basedir, 'source', 'protocol', 'generated')
|
|
|
|
|
write_package(REQUESTS, 'Request',
|
2021-07-11 23:38:23 +01:00
|
|
|
""" with record\n Canceled : Boolean := False with Atomic;\n end record""",
|
2019-07-23 17:33:49 +03:00
|
|
|
join(gen_dir, 'lsp-messages-server_requests.ads'),
|
2019-05-12 13:39:55 +02:00
|
|
|
False)
|
2021-07-11 23:38:23 +01:00
|
|
|
write_package(NOTIFICATIONS, 'Notification', '\n with null record',
|
2019-07-23 17:33:49 +03:00
|
|
|
join(gen_dir, 'lsp-messages-server_notifications.ads'),
|
2019-05-12 13:39:55 +02:00
|
|
|
True)
|
2019-08-02 18:07:17 +03:00
|
|
|
write_body(NOTIFICATIONS, 'Notification',
|
|
|
|
|
join(gen_dir, 'lsp-messages-server_notifications.adb'),
|
|
|
|
|
True)
|
2019-08-02 19:47:39 +03:00
|
|
|
write_body(REQUESTS, 'Request',
|
|
|
|
|
join(gen_dir, 'lsp-messages-server_requests.adb'),
|
|
|
|
|
False)
|
2019-05-02 13:56:57 -04:00
|
|
|
|
2019-07-23 14:12:39 +03:00
|
|
|
|
|
|
|
|
def write_handle_request():
|
|
|
|
|
def write_package(data_array, kind, adb_name, handler_is_procedure):
|
|
|
|
|
"""Factorization function"""
|
|
|
|
|
|
|
|
|
|
# Write the .adb
|
2020-09-13 11:37:00 +01:00
|
|
|
with open(adb_name, 'w') as adb:
|
2019-07-23 14:12:39 +03:00
|
|
|
handler_snippets = ""
|
|
|
|
|
|
|
|
|
|
# Generate the snippets
|
|
|
|
|
for l in data_array:
|
|
|
|
|
protocol_name = l[0]
|
|
|
|
|
request_name = l[1]
|
2019-09-11 14:02:28 +03:00
|
|
|
if handler_is_procedure:
|
|
|
|
|
handler_snippets += \
|
|
|
|
|
C_Handler_Snippet_Procedure.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
kind=kind)
|
2019-07-23 14:12:39 +03:00
|
|
|
else:
|
2019-09-11 14:02:28 +03:00
|
|
|
handler_snippets += \
|
|
|
|
|
C_Handler_Snippet_Function.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
kind=kind)
|
2019-07-23 14:12:39 +03:00
|
|
|
|
|
|
|
|
if handler_is_procedure:
|
|
|
|
|
adb.write(C_Handler_Procedure_Body.format(
|
|
|
|
|
kind=kind,
|
|
|
|
|
handler_snippets=handler_snippets))
|
|
|
|
|
else:
|
|
|
|
|
adb.write(C_Handler_Function_Body.format(
|
|
|
|
|
kind=kind,
|
|
|
|
|
handler_snippets=handler_snippets))
|
|
|
|
|
|
|
|
|
|
gen_dir = join(basedir, 'source', 'server', 'generated')
|
|
|
|
|
write_package(REQUESTS, 'Request',
|
|
|
|
|
join(gen_dir, 'lsp-servers-handle_request.adb'),
|
|
|
|
|
False)
|
|
|
|
|
|
2019-07-23 15:03:09 +03:00
|
|
|
|
2019-07-23 17:10:31 +03:00
|
|
|
|
|
|
|
|
def write_server_handlers():
|
|
|
|
|
""" Write source/server/lsp-server_{request/notification}_handlers.ads """
|
|
|
|
|
|
2019-09-11 14:02:28 +03:00
|
|
|
def write_package(data_array, handler_name,
|
2019-08-02 18:07:17 +03:00
|
|
|
ads_name, handler_is_procedure):
|
2019-07-23 17:10:31 +03:00
|
|
|
"""Factorization function"""
|
|
|
|
|
|
|
|
|
|
# Write the .ads
|
2020-09-13 11:37:00 +01:00
|
|
|
with open(ads_name, 'w') as ads:
|
2019-07-30 20:48:20 +03:00
|
|
|
|
|
|
|
|
ads.write(LSP_Server_Handlers_Header.format(
|
2019-09-11 14:02:28 +03:00
|
|
|
handler=handler_name))
|
2019-07-23 17:10:31 +03:00
|
|
|
|
|
|
|
|
for l in data_array:
|
2019-09-11 14:02:28 +03:00
|
|
|
ads.write(
|
|
|
|
|
C_Method_Function_Snippet.format(
|
|
|
|
|
request_name=l[1],
|
|
|
|
|
response_name=l[3]))
|
2019-07-23 17:10:31 +03:00
|
|
|
|
2019-08-02 19:47:39 +03:00
|
|
|
ads.write("""
|
2019-07-23 17:10:31 +03:00
|
|
|
procedure Handle_Error
|
|
|
|
|
(Self : access Server_Request_Handler) is null;
|
|
|
|
|
-- This procedure will be called when an unexpected error is raised in the
|
|
|
|
|
-- request processing loop.
|
|
|
|
|
""")
|
|
|
|
|
|
2019-08-02 18:07:17 +03:00
|
|
|
ads.write(LSP_Server_Handlers_Footer.format(
|
2019-09-11 14:02:28 +03:00
|
|
|
kind='Request', handler=handler_name))
|
2019-07-23 17:10:31 +03:00
|
|
|
|
2019-08-02 19:47:39 +03:00
|
|
|
gen_dir = join(basedir, 'source', 'server', 'generated')
|
2019-09-11 14:02:28 +03:00
|
|
|
write_package(REQUESTS, 'Handler',
|
2019-07-23 17:10:31 +03:00
|
|
|
join(gen_dir, 'lsp-server_request_handlers.ads'),
|
|
|
|
|
False)
|
2019-08-02 19:47:39 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_server_receivers():
|
|
|
|
|
""" Write source/server/lsp-server_{request/notification}_handlers.ads """
|
|
|
|
|
|
|
|
|
|
def write_package(data_array, kind, handler_name,
|
|
|
|
|
ads_name, is_request):
|
|
|
|
|
"""Factorization function"""
|
|
|
|
|
|
|
|
|
|
# Write the .ads
|
2020-09-13 11:37:00 +01:00
|
|
|
with open(ads_name, 'w') as ads:
|
2019-09-11 14:02:28 +03:00
|
|
|
ads.write(LSP_Server_Recievers_Header.format(
|
|
|
|
|
kind=kind, handler=handler_name,
|
|
|
|
|
extra_with=".Server_Requests" if is_request else""))
|
2019-08-02 19:47:39 +03:00
|
|
|
|
|
|
|
|
for l in data_array:
|
|
|
|
|
request_name = l[1]
|
|
|
|
|
params_name = l[2]
|
|
|
|
|
if params_name:
|
|
|
|
|
if is_request:
|
|
|
|
|
ads.write(
|
|
|
|
|
C_Method_Request_Snippet.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
params_name=params_name,
|
|
|
|
|
response_name=l[3],
|
|
|
|
|
kind=kind))
|
|
|
|
|
else:
|
|
|
|
|
ads.write(
|
|
|
|
|
C_Method_Procedure_Snippet.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
params_name=params_name,
|
|
|
|
|
kind=kind))
|
|
|
|
|
else:
|
|
|
|
|
if is_request:
|
|
|
|
|
ads.write(
|
|
|
|
|
C_Method_Request_Snippet.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
params_name=params_name,
|
|
|
|
|
response_name=l[3],
|
|
|
|
|
kind=kind))
|
|
|
|
|
else:
|
|
|
|
|
ads.write(
|
|
|
|
|
C_Method_Procedure_Snippet_Noparam.format(
|
|
|
|
|
request_name=request_name,
|
|
|
|
|
kind=kind))
|
|
|
|
|
|
|
|
|
|
ads.write(LSP_Server_Handlers_Footer.format(
|
|
|
|
|
kind=kind, handler=handler_name))
|
|
|
|
|
|
|
|
|
|
gen_dir = join(basedir, 'source', 'protocol', 'generated')
|
|
|
|
|
write_package(REQUESTS, 'Request', 'Receiver',
|
|
|
|
|
join(gen_dir, 'lsp-server_request_receivers.ads'),
|
|
|
|
|
True)
|
2019-08-02 18:07:17 +03:00
|
|
|
write_package(NOTIFICATIONS, 'Notification', 'Receiver',
|
|
|
|
|
join(gen_dir, 'lsp-server_notification_receivers.ads'),
|
2019-08-02 19:47:39 +03:00
|
|
|
False)
|
2019-07-23 17:10:31 +03:00
|
|
|
|
|
|
|
|
|
2019-05-02 13:56:57 -04:00
|
|
|
if __name__ == '__main__':
|
2019-05-03 15:55:40 -04:00
|
|
|
write_message_types()
|
2019-07-23 14:12:39 +03:00
|
|
|
write_handle_request()
|
2019-07-23 17:10:31 +03:00
|
|
|
write_server_handlers()
|
2019-08-02 19:47:39 +03:00
|
|
|
write_server_receivers()
|