15
15
-- of the license. --
16
16
-- ----------------------------------------------------------------------------
17
17
18
+ with Ada.Containers.Indefinite_Vectors ;
18
19
with GPR2.Project.View ;
19
20
20
21
with VSS.JSON.Streams ;
21
22
22
23
package body LSP.Ada_Handlers.Mains_Commands is
23
24
25
+ package Main_Vectors is
26
+ new Ada.Containers.Indefinite_Vectors (Positive, String);
27
+
24
28
-- ----------
25
29
-- Create --
26
30
-- ----------
@@ -54,8 +58,8 @@ package body LSP.Ada_Handlers.Mains_Commands is
54
58
Response.Value.Append (Item);
55
59
end Append ;
56
60
57
- Value : VSS.Strings.Virtual_String ;
58
- Element : GPR2.Project.View.Object ;
61
+ Element : GPR2.Project.View.Object ;
62
+ Main_Paths : Main_Vectors.Vector ;
59
63
begin
60
64
Response := (Is_Null => False, Value => <>);
61
65
Append ((Kind => VSS.JSON.Streams.Start_Array));
@@ -65,14 +69,25 @@ package body LSP.Ada_Handlers.Mains_Commands is
65
69
66
70
if Element.Has_Mains then
67
71
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 ;
72
81
end loop ;
73
82
end if ;
74
83
end if ;
75
84
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
+
76
91
Append ((Kind => VSS.JSON.Streams.End_Array));
77
92
end Execute ;
78
93
0 commit comments