Skip to content

Commit fc04b57

Browse files
committed
Merge branch 'als_1739' into 'master'
Added extendedProject field for locations See merge request eng/ide/ada_language_server!2160
2 parents 52a78a2 + 1f29c2c commit fc04b57

23 files changed

+362
-30
lines changed

doc/metaModel.patch.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,15 @@
422422
}
423423
},
424424
"optional": true
425+
},
426+
{
427+
"name": "hidden",
428+
"type": {
429+
"kind": "base",
430+
"name": "boolean"
431+
},
432+
"optional": true,
433+
"documentation": "Set to True if the location is from the hidden source file (extended project)"
425434
}
426435
]
427436
},

doc/reference_kinds.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ be 'write', 'parent', 'dispatching call', etc.
1010

1111
We extend the result of `textDocument/references` by adding an
1212
extra field to the `Location` type:
13+
alsKind field represents the reference kind
14+
hidden field is set to True if the location is from the hidden source file (extended project)
1315

1416
```typescript
1517

@@ -28,6 +30,7 @@ interface Location {
2830
uri: DocumentUri;
2931
range: Range;
3032
alsKind?: AlsReferenceKind[];
33+
hidden?: boolean;
3134
}
3235
```
3336

liblsp_3_16/source/generated/lsp-message_io.adb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ package body LSP.Message_IO is
449449
LSP.Messages.Span'Read (S, V.span);
450450
elsif Key = "alsKind" then
451451
AlsReferenceKind_Set'Read (S, V.alsKind);
452+
elsif Key = "hidden" then
453+
Optional_Boolean'Read (S, V.hidden);
452454
else
453455
JS.Skip_Value;
454456
end if;
@@ -471,6 +473,8 @@ package body LSP.Message_IO is
471473
LSP.Messages.Span'Write (S, V.span);
472474
JS.Key ("alsKind");
473475
AlsReferenceKind_Set'Write (S, V.alsKind);
476+
JS.Key ("hidden");
477+
Optional_Boolean'Write (S, V.hidden);
474478
JS.End_Object;
475479
end Write_Location;
476480

liblsp_3_16/source/lsp-messages.ads

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2023, AdaCore --
4+
-- Copyright (C) 2018-2025, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -515,6 +515,7 @@ package LSP.Messages is
515515
-- uri: DocumentUri;
516516
-- range: Range;
517517
-- AlsKind?: AlsReferenceKind[];
518+
-- hidden?: boolean;
518519
--}
519520
--```
520521
--
@@ -525,6 +526,7 @@ package LSP.Messages is
525526
uri : DocumentUri;
526527
span : LSP.Messages.Span; -- range: is reserved word
527528
alsKind : AlsReferenceKind_Set := Empty_Set;
529+
hidden : Optional_Boolean;
528530
end record;
529531

530532
overriding function "=" (Left, Right : Location) return Boolean;

liblsp_3_17/source/generated/lsp-inputs-part_9.adb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,12 @@ package body LSP.Inputs.Part_9 is
603603
Read_A_Range (Handler, Value.a_range);
604604
when 3 => -- alsKind
605605
Read_AlsReferenceKind_Set (Handler, Value.alsKind);
606+
when 4 => -- hidden
607+
Value.hidden :=
608+
(Is_Set => True,
609+
Value => <>);
610+
Value.hidden.Value := Handler.Boolean_Value;
611+
Handler.Read_Next;
606612
when others =>
607613
Handler.Skip_Current_Value;
608614
end case;

liblsp_3_17/source/generated/lsp-outputs.adb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6682,6 +6682,10 @@ package body LSP.Outputs is
66826682
Handler.Key_Name ("alsKind");
66836683
Write_AlsReferenceKind_Set (Handler, Value.alsKind);
66846684
end if;
6685+
if Value.hidden.Is_Set then
6686+
Handler.Key_Name ("hidden");
6687+
Handler.Boolean_Value (Value.hidden.Value);
6688+
end if;
66856689
Handler.End_Object;
66866690
end Write_Location;
66876691

liblsp_3_17/source/generated/lsp-structures.ads

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,6 +3008,8 @@ package LSP.Structures is
30083008

30093009
alsKind : LSP.Structures.AlsReferenceKind_Set;
30103010

3011+
hidden : Boolean_Optional;
3012+
30113013
end record;
30123014
-- Represents a location inside a resource, such as a line inside a text
30133015
-- file.

source/ada/lsp-ada_documents.adb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,11 +1172,16 @@ package body LSP.Ada_Documents is
11721172
function To_LSP_Location
11731173
(Self : Document;
11741174
Segment : Langkit_Support.Slocs.Source_Location_Range;
1175-
Kinds : LSP.Structures.AlsReferenceKind_Set := LSP.Constants.Empty)
1175+
Kinds : LSP.Structures.AlsReferenceKind_Set := LSP.Constants.Empty;
1176+
Hidden : Boolean := False)
11761177
return LSP.Structures.Location
11771178
is (uri => Self.URI,
11781179
a_range => Self.To_A_Range (Segment),
1179-
alsKind => Kinds);
1180+
alsKind => Kinds,
1181+
hidden =>
1182+
(if Hidden
1183+
then (Is_Set => True, Value => True)
1184+
else (Is_Set => False)));
11801185

11811186
----------
11821187
-- Unit --

source/ada/lsp-ada_documents.ads

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ package LSP.Ada_Documents is
6363
function To_LSP_Location
6464
(Self : Document;
6565
Segment : Langkit_Support.Slocs.Source_Location_Range;
66-
Kinds : LSP.Structures.AlsReferenceKind_Set := LSP.Constants.Empty)
66+
Kinds : LSP.Structures.AlsReferenceKind_Set := LSP.Constants.Empty;
67+
Hidden : Boolean := False)
6768
return LSP.Structures.Location;
6869
-- Convert LAL's Source_Location_Range and document's uri to a LSP location
6970

source/ada/lsp-ada_handlers-locations.adb

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ package body LSP.Ada_Handlers.Locations is
5858
Value : constant LSP.Structures.Location :=
5959
(uri => URI,
6060
a_range => Locations.To_LSP_Range (Self, Unit, Token),
61-
alsKind => LSP.Constants.Empty);
61+
alsKind => LSP.Constants.Empty,
62+
hidden => (Is_Set => False));
6263
begin
6364
if not Filter.Contains (Value) then
6465
Result.Append (Value);
@@ -423,13 +424,22 @@ package body LSP.Ada_Handlers.Locations is
423424

424425
begin
425426
if Doc /= null then
426-
return Doc.To_LSP_Location (Sloc, Kinds);
427+
return Doc.To_LSP_Location
428+
(Segment => Sloc,
429+
Kinds => Kinds,
430+
Hidden => LSP.Utils.Is_From_Extended_Project
431+
(Self.Project_Tree, File));
432+
427433
else
428434
return
429435
(uri => URI,
430436
a_range => To_LSP_Range
431437
(Context.Get_AU (GNATCOLL.VFS.Create_From_UTF8 (File)), Sloc),
432-
alsKind => Kinds);
438+
alsKind => Kinds,
439+
hidden =>
440+
(if LSP.Utils.Is_From_Extended_Project (Self.Project_Tree, File)
441+
then (Is_Set => True, Value => True)
442+
else (Is_Set => False)));
433443
end if;
434444
end To_LSP_Location;
435445

@@ -507,14 +517,22 @@ package body LSP.Ada_Handlers.Locations is
507517

508518
begin
509519
if Doc /= null then
510-
return Doc.To_LSP_Location (Sloc, Kind);
520+
return Doc.To_LSP_Location
521+
(Segment => Sloc,
522+
Kinds => Kind,
523+
Hidden => LSP.Utils.Is_From_Extended_Project
524+
(Self.Project_Tree, Node.Unit.Get_Filename));
511525

512526
else
513527
return
514-
(uri => URI,
528+
(uri => URI,
515529
a_range => To_LSP_Range (Node.Unit, Sloc),
516-
alsKind => Kind);
517-
530+
alsKind => Kind,
531+
hidden =>
532+
(if LSP.Utils.Is_From_Extended_Project
533+
(Self.Project_Tree, Node.Unit.Get_Filename)
534+
then (Is_Set => True, Value => True)
535+
else (Is_Set => False)));
518536
end if;
519537
end To_LSP_Location;
520538

0 commit comments

Comments
 (0)