Skip to content

Commit 4d65c6a

Browse files
committed
Merge branch 'topic/doc_sym' into 'master'
Rewrite document symbol, tokens requests as jobs See merge request eng/ide/ada_language_server!1541
2 parents 087a0ed + a6c24cc commit 4d65c6a

21 files changed

+1916
-1245
lines changed

source/ada/lsp-ada_document_symbol.adb

Lines changed: 768 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
------------------------------------------------------------------------------
2+
-- Language Server Protocol --
3+
-- --
4+
-- Copyright (C) 2024, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it under --
7+
-- terms of the GNU General Public License as published by the Free Soft- --
8+
-- ware Foundation; either version 3, or (at your option) any later ver- --
9+
-- sion. This software is distributed in the hope that it will be useful, --
10+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
12+
-- License for more details. You should have received a copy of the GNU --
13+
-- General Public License distributed with this software; see file --
14+
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
15+
-- of the license. --
16+
------------------------------------------------------------------------------
17+
18+
-- This package provides handler and job types for textDocument/documentSymbol
19+
-- requests.
20+
21+
with LSP.Ada_Job_Contexts;
22+
with LSP.Server_Jobs;
23+
with LSP.Server_Message_Handlers;
24+
with LSP.Server_Messages;
25+
26+
package LSP.Ada_Document_Symbol is
27+
28+
type Ada_Document_Symbol_Handler
29+
(Context : not null access LSP.Ada_Job_Contexts.Ada_Job_Context'Class) is
30+
limited new LSP.Server_Message_Handlers.Server_Message_Handler
31+
with null record;
32+
33+
overriding function Create_Job
34+
(Self : Ada_Document_Symbol_Handler;
35+
Message : LSP.Server_Messages.Server_Message_Access)
36+
return LSP.Server_Jobs.Server_Job_Access;
37+
38+
end LSP.Ada_Document_Symbol;

source/ada/lsp-ada_documents.adb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,18 +1139,6 @@ package body LSP.Ada_Documents is
11391139
is
11401140
(Self.Unit (Context).Lookup_Token (Self.To_Source_Location (Position)));
11411141

1142-
----------------
1143-
-- Get_Tokens --
1144-
----------------
1145-
1146-
function Get_Tokens
1147-
(Self : Document'Class; Context : LSP.Ada_Contexts.Context;
1148-
Highlighter : LSP.Ada_Highlighters.Ada_Highlighter;
1149-
Span : LSP.Structures.A_Range := ((1, 1), (0, 0)))
1150-
return LSP.Structures.Natural_Vector
1151-
is
1152-
(Highlighter.Get_Tokens (Self.Unit (Context), Context.Tracer.all, Span));
1153-
11541142
-----------------
11551143
-- Get_Word_At --
11561144
-----------------

source/ada/lsp-ada_documents.ads

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ with Pp.Command_Lines;
3232
limited with LSP.Ada_Contexts;
3333
limited with LSP.Ada_Handlers;
3434
with LSP.Ada_Completions;
35-
with LSP.Ada_Highlighters;
3635
with LSP.Constants;
3736
with LSP.Diagnostic_Sources;
3837
with LSP.Text_Documents.Langkit_Documents;
@@ -286,14 +285,6 @@ package LSP.Ada_Documents is
286285
return Libadalang.Common.Token_Reference;
287286
-- Return a token at the given Position.
288287

289-
function Get_Tokens
290-
(Self : Document'Class;
291-
Context : LSP.Ada_Contexts.Context;
292-
Highlighter : LSP.Ada_Highlighters.Ada_Highlighter;
293-
Span : LSP.Structures.A_Range := ((1, 1), (0, 0)))
294-
return LSP.Structures.Natural_Vector;
295-
-- Return semantic tokens in the document. See details in LSP specification
296-
297288
private
298289

299290
type Name_Information is record

source/ada/lsp-ada_driver.adb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ with GNATCOLL.Utils;
4040
with LSP.Ada_Commands;
4141
with LSP.Ada_Definition;
4242
with LSP.Ada_Declaration;
43+
with LSP.Ada_Document_Symbol;
4344
with LSP.Ada_Did_Change_Configurations;
4445
with LSP.Ada_Did_Change_Document;
4546
with LSP.Ada_Hover;
@@ -68,6 +69,8 @@ with LSP.Ada_Handlers.Refactor.Suppress_Seperate;
6869
with LSP.Ada_Handlers.Show_Dependencies_Commands;
6970
with LSP.Ada_Handlers.Source_Dirs_Commands;
7071
with LSP.Ada_Handlers.Suspend_Executions;
72+
with LSP.Ada_Tokens_Full;
73+
with LSP.Ada_Tokens_Range;
7174
with LSP.GNATCOLL_Trace_Streams;
7275
with LSP.GNATCOLL_Tracers;
7376
with LSP.GPR_Handlers;
@@ -80,8 +83,11 @@ with LSP.Server_Notifications.DidChange;
8083
with LSP.Server_Notifications.DidChangeConfiguration;
8184
with LSP.Server_Requests.Definition;
8285
with LSP.Server_Requests.Declaration;
86+
with LSP.Server_Requests.DocumentSymbol;
8387
with LSP.Server_Requests.Hover;
8488
with LSP.Server_Requests.References;
89+
with LSP.Server_Requests.Tokens_Full;
90+
with LSP.Server_Requests.Tokens_Range;
8591
with LSP.Servers;
8692
with LSP.Stdio_Streams;
8793

@@ -201,6 +207,18 @@ procedure LSP.Ada_Driver is
201207
LSP.Ada_Declaration.Ada_Declaration_Handler
202208
(Ada_Handler'Unchecked_Access);
203209

210+
Ada_Document_Symbol_Handler : aliased
211+
LSP.Ada_Document_Symbol.Ada_Document_Symbol_Handler
212+
(Ada_Handler'Unchecked_Access);
213+
214+
Ada_Tokens_Full_Handler : aliased
215+
LSP.Ada_Tokens_Full.Ada_Tokens_Full_Handler
216+
(Ada_Handler'Unchecked_Access);
217+
218+
Ada_Tokens_Range_Handler : aliased
219+
LSP.Ada_Tokens_Range.Ada_Tokens_Range_Handler
220+
(Ada_Handler'Unchecked_Access);
221+
204222
GPR_Did_Change_Doc_Handler : aliased
205223
LSP.GPR_Did_Change_Document.GPR_Did_Change_Handler
206224
(GPR_Handler'Unchecked_Access);
@@ -421,6 +439,18 @@ begin
421439
(LSP.Server_Requests.Declaration.Request'Tag,
422440
Ada_Declaration_Handler'Unchecked_Access);
423441

442+
Server.Register_Handler
443+
(LSP.Server_Requests.DocumentSymbol.Request'Tag,
444+
Ada_Document_Symbol_Handler'Unchecked_Access);
445+
446+
Server.Register_Handler
447+
(LSP.Server_Requests.Tokens_Full.Request'Tag,
448+
Ada_Tokens_Full_Handler'Unchecked_Access);
449+
450+
Server.Register_Handler
451+
(LSP.Server_Requests.Tokens_Range.Request'Tag,
452+
Ada_Tokens_Range_Handler'Unchecked_Access);
453+
424454
Server.Register_Handler
425455
(LSP.Server_Requests.References.Request'Tag,
426456
Ada_References_Handler'Unchecked_Access);

0 commit comments

Comments
 (0)