File tree Expand file tree Collapse file tree 4 files changed +50
-13
lines changed Expand file tree Collapse file tree 4 files changed +50
-13
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,14 @@ package body LSP.Ada_Configurations is
205205 and then JSON (Index).Kind = Start_Object
206206 then
207207 Parse_Variables (Index);
208+ Sort_Variables (1 , Variables_Names.Length);
209+
210+ Reload := Reload or else
211+ Variables_Names /= Self.Variables_Names or else
212+ Variables_Values /= Self.Variables_Values;
213+
214+ Self.Variables_Names := Variables_Names;
215+ Self.Variables_Values := Variables_Values;
208216
209217 elsif Name = " defaultCharset"
210218 and then JSON (Index).Kind = String_Value
@@ -288,15 +296,6 @@ package body LSP.Ada_Configurations is
288296
289297 Skip_Value (JSON, Index);
290298 end loop ;
291-
292- Sort_Variables (1 , Variables_Names.Length);
293-
294- Reload := Reload or else
295- Variables_Names /= Self.Variables_Names or else
296- Variables_Values /= Self.Variables_Values;
297-
298- Self.Variables_Names := Variables_Names;
299- Self.Variables_Values := Variables_Values;
300299 end Parse_Ada ;
301300
302301 -- ------------------
Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ begin
381381
382382 Server.Finalize;
383383 if Clean_ALS_Dir then
384- pragma Assert (Clean_ALS_Dir );
384+ Ada_Handler.Clean_Logs (ALS_Dir );
385385 end if ;
386386
387387 -- Clean secondary stack up
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ with Ada.Unchecked_Deallocation;
2323
2424with GNAT.OS_Lib ;
2525with GNATCOLL.Traces ;
26+ with GNATCOLL.Utils ;
2627
2728with VSS.Characters.Latin ;
2829with VSS.Strings.Formatters.Integers ;
@@ -216,6 +217,34 @@ package body LSP.Ada_Handlers is
216217 end if ;
217218 end Clean_Diagnostics ;
218219
220+ -- --------------
221+ -- Clean_Logs --
222+ -- --------------
223+
224+ procedure Clean_Logs
225+ (Self : access Message_Handler'Class;
226+ Dir : GNATCOLL.VFS.Virtual_File)
227+ is
228+ use GNATCOLL.VFS;
229+ Files : File_Array_Access := Read_Dir (Dir, Files_Only);
230+ Dummy : Boolean;
231+ Cpt : Integer := 0 ;
232+ begin
233+ Sort (Files.all );
234+ -- Browse the log files in reverse timestamp order
235+ for F of reverse Files.all loop
236+ -- Filter out files like traces.cfg
237+ if GNATCOLL.Utils.Ends_With (+F.Base_Name, " .log" ) then
238+ Cpt := Cpt + 1 ;
239+ -- Delete the old logs
240+ if Cpt > Self.Configuration.Log_Threshold then
241+ Delete (F, Dummy);
242+ end if ;
243+ end if ;
244+ end loop ;
245+ Unchecked_Free (Files);
246+ end Clean_Logs ;
247+
219248 -- ---------------------
220249 -- Contexts_For_File --
221250 -- ---------------------
Original file line number Diff line number Diff line change @@ -87,9 +87,9 @@ package LSP.Ada_Handlers is
8787 return LSP.Structures.ProgressToken;
8888 -- Return an unique token for indicating progress
8989
90- -- --------------------------
91- -- Open Document Manger --
92- -- --------------------------
90+ -- ---------------------------
91+ -- Open Document Manager --
92+ -- ---------------------------
9393
9494 function Get_Open_Document
9595 (Self : in out Message_Handler;
@@ -125,6 +125,15 @@ package LSP.Ada_Handlers is
125125 -- If the document is not opened, then it returns a
126126 -- OptionalVersionedTextDocumentIdentifier with a null version.
127127
128+ -- ---------------
129+ -- Log Manager --
130+ -- ---------------
131+
132+ procedure Clean_Logs
133+ (Self : access Message_Handler'Class;
134+ Dir : GNATCOLL.VFS.Virtual_File);
135+ -- Remove the oldest logs in Dir
136+
128137private
129138
130139 type Load_Project_Status is
You can’t perform that action at this time.
0 commit comments