1515-- of the license. --
1616-- ----------------------------------------------------------------------------
1717
18+ with Ada.Containers.Indefinite_Vectors ;
1819with GPR2.Project.View ;
1920
2021with VSS.JSON.Streams ;
2122
2223package body LSP.Ada_Handlers.Mains_Commands is
2324
25+ package Main_Vectors is
26+ new Ada.Containers.Indefinite_Vectors (Positive, String);
27+
2428 -- ----------
2529 -- Create --
2630 -- ----------
@@ -54,8 +58,8 @@ package body LSP.Ada_Handlers.Mains_Commands is
5458 Response.Value.Append (Item);
5559 end Append ;
5660
57- Value : VSS.Strings.Virtual_String ;
58- Element : GPR2.Project.View.Object ;
61+ Element : GPR2.Project.View.Object ;
62+ Main_Paths : Main_Vectors.Vector ;
5963 begin
6064 Response := (Is_Null => False, Value => <>);
6165 Append ((Kind => VSS.JSON.Streams.Start_Array));
@@ -65,14 +69,25 @@ package body LSP.Ada_Handlers.Mains_Commands is
6569
6670 if Element.Has_Mains then
6771 for Main of Element.Mains loop
68- Value := VSS.Strings.Conversions.To_Virtual_String
69- (String (Main.Source.Value));
70-
71- Append ((VSS.JSON.Streams.String_Value, Value));
72+ declare
73+ Main_Path : constant String := String (Main.Source.Value);
74+ begin
75+ -- Avoid duplicates coming from GPR2
76+ -- Workaround for eng/ide/gpr-issues#417
77+ if not Main_Paths.Contains (Main_Path) then
78+ Main_Paths.Append (Main_Path);
79+ end if ;
80+ end ;
7281 end loop ;
7382 end if ;
7483 end if ;
7584
85+ for Main_Path of Main_Paths loop
86+ Append
87+ ((VSS.JSON.Streams.String_Value,
88+ VSS.Strings.Conversions.To_Virtual_String (Main_Path)));
89+ end loop ;
90+
7691 Append ((Kind => VSS.JSON.Streams.End_Array));
7792 end Execute ;
7893
0 commit comments