@@ -341,6 +341,7 @@ package body LSP.GPR_Handlers is
341
341
342
342
Capabilities.hoverProvider := LSP.Constants.True;
343
343
Capabilities.definitionProvider := LSP.Constants.True;
344
+ Capabilities.declarationProvider := LSP.Constants.True;
344
345
Capabilities.completionProvider :=
345
346
(Is_Set => True,
346
347
Value => (triggerCharacters => [" " ],
@@ -431,6 +432,55 @@ package body LSP.GPR_Handlers is
431
432
Self.Sender.On_Completion_Resolve_Response (Id, Response);
432
433
end On_Completion_Resolve_Request ;
433
434
435
+ -- --------------------------
436
+ -- On_Declaration_Request --
437
+ -- --------------------------
438
+
439
+ overriding procedure On_Declaration_Request
440
+ (Self : in out Message_Handler;
441
+ Id : LSP.Structures.Integer_Or_Virtual_String;
442
+ Value : LSP.Structures.DeclarationParams)
443
+ is
444
+ procedure Fill_Declaration ;
445
+ -- Utility function, appends to Vector the definition if any.
446
+
447
+ Response : LSP.Structures.Declaration_Result (LSP.Structures.Variant_1);
448
+
449
+ -- --------------------
450
+ -- Fill_Declaration --
451
+ -- --------------------
452
+
453
+ procedure Fill_Declaration is
454
+ File : constant LSP.GPR_Files.File_Access :=
455
+ LSP.GPR_Files.Parse
456
+ (File_Provider => Self'Unchecked_Access,
457
+ Path => Self.To_File
458
+ (Value.textDocument.uri));
459
+
460
+ Reference : constant Gpr_Parser.Common.Token_Reference :=
461
+ LSP.GPR_Files.References.Token_Reference
462
+ (File, Value.position);
463
+
464
+ Location : LSP.Structures.Location;
465
+
466
+ use type Gpr_Parser.Common.Token_Reference;
467
+
468
+ begin
469
+ if Reference /= Gpr_Parser.Common.No_Token then
470
+ Location.uri :=
471
+ LSP.GPR_File_Readers.To_URI (Reference.Origin_Filename);
472
+ Location.a_range := To_Range (Self'Unchecked_Access, Reference);
473
+ Response.Variant_1.Append (Location);
474
+ end if ;
475
+
476
+ end Fill_Declaration ;
477
+
478
+ begin
479
+ Fill_Declaration;
480
+
481
+ Self.Sender.On_Declaration_Response (Id, Response);
482
+ end On_Declaration_Request ;
483
+
434
484
-- -------------------------
435
485
-- On_Definition_Request --
436
486
-- -------------------------
0 commit comments